How to change the client prompt in MySQL?

Change MySQL’s prompt by using the prompt command:

mysql>prompt mysql (\d)>

Once executed, the currently selected database will appear in the prompt, like so:

mysql (mydatabase)>

It’s also easy to lose track of which database server you’re logged in to, not to mention which account you’re using. To fix this, modify your prompt using the \u and \h options:

mysql>prompt mysql (\u@\h)>

This produces a prompt similar to the following:

mysql (root@www.actsupport.com)>

To render the change permanent, add the command to your .my.cnf file like so:

[mysql] prompt=mysql \\d>

Written by actsupp-r0cks