In hive, I can set the prompt to be the currently selected database. Is it possible to do the same in MySQL?
I want to replace mysql with kundoor in the image below.
In hive, I can set the prompt to be the currently selected database. Is it possible to do the same in MySQL?
I want to replace mysql with kundoor in the image below.
On
Type this in your terminal
export MYSQL_PS1="\u@\h [\d]> "
This will create the following
user@host [databasename]>
On
In addition to using the MYSQL_PS1 environment variable @Noob describes, you can use the prompt command within the mysql client:
mysql> prompt \u@\h [\d]
(type a space at the end of the line to get a space after the prompt)
See https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html for more on mysql client commands.
You can make this default by editing your MySQL options file:
[mysql]
prompt \u@\h [\d]
For example, using
--prompt=(--prompt), you can change the default promptmysql>toapple>ofappledatabase with login as shown below. *\dis the current database but if the current database is not selected,\dis(none)and\_is a space according to the doc:Or:
Or:
Or, using
prompt(PROMPT) or\R, you can change the default promptmysql>toapple>ofappledatabase after login as shown below. *Don't forget to put a spacejust after\d>:Or:
Or:
Or:
Or on Windows, you can set the prompt under
[mysql]inmy.inias shown below. *My answer explains[mysql]and my answer explains wheremy.iniis located on Windows:Or:
Or:
Then, you can change the default prompt
mysql>toapple>ofappledatabase with login by settingmy.ini's location to--defaults-file=or--defaults-extra-file=as shown below. *--defaults-file=or--defaults-extra-file=must be the 1st option otherwise there is the error:Or: