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 :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>