Tag Archives: bashrc

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:

export MYSQL_PS1="mysql@\d > "

Don’t forget to relaunch it:

source ~/.bashrc

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

Sweet :)