MariaDB – How to Set Prompt for MariaDB 10.2 in my.cnf

mariadb

I'd like to set the default prompt on MariaDB across all our database servers for everyone. I assume this would be best done in my.cnf. I can set the prompt in a session, but when I try to add something like prompt=name[/d]>/_ in my.cnf, MariaDB fails to start an complains about it.

What is the proper way to do this?

Best Answer

across all our database servers for everyone

This is a function of the client. You can't set it on the server. MySQL ships with a client, and a server. The client determines the prompt. There is nothing you can do on the server to fix that. The client could be something totally different that has for its prompt

L33tHAX\###->#

You can see the code here construct_prompt(). Nothing there hits the server. That said, it gets set here in the main

default_prompt = my_strdup(getenv("MYSQL_PS1") ? 
                 getenv("MYSQL_PS1") : 
                 "\\N [\\d]> ",MYF(MY_WME));
current_prompt = my_strdup(default_prompt,MYF(MY_WME));

So it would seem you could set it through the MYSQL_PS1 environmental variable.