Tag Archives: terminal

Show current database on mysql console

I’m sure everyone has at least once deleted something on the wrong database…

In an attempt to avoid that you can rewrite mysql’s PS1 value in order to display the current database you’re on.

Just edit your ~/.bashrc:

1
export MYSQL_PS1="mysql@\d > "

Don’t forget to relaunch it:

1
source ~/.bashrc

Et voila, the old “mysql>” is now replaced with “mysql@current_database>

Sweet :)