mysqllinuxdatabasepromptmysql-command-line-client

How to change the MySQL prompt from the command line


I bet this is easy and I have surely overseen something:

I am trying to set the "internal" MySQL prompt from the Bash shell as an argument to the command mysql.

The manual makes reference a command line option called --named-command=str where I assumed that I could pass any of the commands referred here:

mysql Command-line Client

But an version of the command below return an error after connecting to the DB:

mysql --named-commands='\R >'
mysql --named-commands="\R >"

The error reads:

Warning: mysql: ignoring option '--named-commands' due to invalid value '\R > '

I thus assume that I am missing something. Please note that I have already gone through the MySQL manual/s (both, the Oracle site and the MariaDB site). The fact is that the question itself is not easy to define as when I t yto google for "Mysql Command line option" it normally takes me to the "internal" MySQL command line (or more exactly, the MySQL command line client).

Thanks for your suggestion :)


Solution

  • mysql -h hostname -u username -p --prompt myCustomPrompt\>

    Be sure to escape > with \ in order to avoid a bash syntax error. See the final section of mysql client commands for instructions on special characters to use in the prompt command.