[Raleigh-talk] modifying the mysql prompt

Brad Oaks bradoaks at gmail.com
Thu Jun 25 13:40:02 PDT 2009


Trevor asked a question on #raleigh.pm channel (on the irc.perl.org
servers) about giving yourself some visual cues that a given window is
connected to production or development databases.

I didn't come up with a way to colorize certain windows within gnu
screen differently (holler if you do), but I did find out that the
prompt within the mysql client is easy to modify.  Below is what I'm
using.  If you don't have a shared home directory between development
and production, you could easily add 'PRODUCTION' to your prompt in
that environment.

"man mysql" lists what's available to put into your prompt.  You can
issue the command (without escaping the backslashes) directly in the
client, or have the change persist by editing your config file.

The setting below gives me a mysql prompt like this on my laptop:
(krang at localhost) [foo_arcos]>

Production looks different now, and that's nice.

Thanks for asking the question Trevor!
--bradoaks

Put this in your ~/.my.cnf file:
[mysql]
prompt="(\\u@\\h) [\\d]> "


More information about the Raleigh-talk mailing list