Correctlysettingyourmysqlpromptusingsudo_MySQL
來源:懂視網
責編:小采
時間:2020-11-09 19:18:51
Correctlysettingyourmysqlpromptusingsudo_MySQL
Correctlysettingyourmysqlpromptusingsudo_MySQL:If you run multiple MySQL environments on multiple servers its a good habit to set your MySQL prompt to double check which server you are on.however, using the MYSQL_PS1 environm
導讀Correctlysettingyourmysqlpromptusingsudo_MySQL:If you run multiple MySQL environments on multiple servers its a good habit to set your MySQL prompt to double check which server you are on.however, using the MYSQL_PS1 environm

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.
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
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
Correctlysettingyourmysqlpromptusingsudo_MySQL
Correctlysettingyourmysqlpromptusingsudo_MySQL:If you run multiple MySQL environments on multiple servers its a good habit to set your MySQL prompt to double check which server you are on.however, using the MYSQL_PS1 environm