MySQL

Customize PS1

Customize the MySQL PS1 with current database

In the .bashrc or .bash_profile, adding:

export MYSQL_PS1="\u@\h [\d]>"

make the MySQL client PROMPT show current user@host [database].

enter image description here

Custom PS1 via MySQL configuration file

In mysqld.cnf or equivalent:

[mysql]
prompt = '\u@\h [\d]> '

This achieves a similar effect, without having to deal with .bashrc‘s.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow