if you run multiple mysql environments on multiple servers it’s a good habit to set your mysql prompt to double check which server you are on.
however, using the mysql_ps1 environment variable i found this does not work under sudo (the normal way people run sudo).
I.e., the following syntax’s work.
$ mysql$ sudo su - -c mysql$ sudo su - ; mysql
but the following does not.
$ sudo mysql
The trick is actually to ensure via /etc/sudoers you inherit the MySQL_PS1 environment variable.
echo "export MYSQL_PS1=/"`hostname` [/d]> /"" | sudo tee /etc/profile.d/mysql.shecho 'Defaultsenv_keep += "MYSQL_PS1"' | sudo tee /tmp/mysqlsudo chmod 400 /tmp/mysqlsudo mv /tmp/mysql /etc/sudoers.d
Tags:mysql client,mysql prompt,MYSQL_PS1,sudo
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号