The prompt command reconfigures the default mysql> prompt. The string for defining the prompt can contain the following special sequences.
The default prompt for the MySQL console program is "Mysql>". The prompt can be modified to suit your needs:
There are several ways to set this up:
Set the shell's environment variable: MYSQL_PS1
Shell> Export mysql_ps1= "(\u@\h) [\d]>"
Use program startup command options:--prompt
shell> MySQL--prompt= "(\u@\h) [\d]>"
(User@host) [database]>
Set the [MySQL] section in the options file, add the Prompt option
[MySQL]
prompt= (\\u@\\h) [\\d]>\\_
Using the prompt (\ r) command in a MySQL program
mysql> prompt (\u@\h) [\d]>\_
PROMPT set to ' (\u@\h) [\d]>\_ '
(User@host) [database]>
(User@host) [database]> prompt
Returning to default PROMPT of mysql>
Mysql>
Some special escape strings in the prompt
Option |
Description |
\c |
A counter that increments for each statement to you issue |
\D |
The full current date |
\d |
The default database |
\h |
The server host |
\l |
The current delimiter (new in 5.1.12) |
\m |
Minutes of the current time |
\n |
A newline character |
\O |
The current month in three-letter format (no, Feb, ...) |
\o |
The current month in numeric format |
\P |
am/pm |
\p |
The current TCP/IP port or socket file |
\R |
The 24-hour military Time (0–23) |
\r |
The standard 12-hour time (1–12) |
\S |
Semicolon |
\s |
Seconds of the current time |
\t |
A Tab character |
\u |
Your full user_name @host_name account name /strong> |
\u |
Your User Name |
\v |
The server version |
\w |
The week in Three-letter format (Mon, Tue, ...) |
\Y |
The current year, four digits |
\y |
The current year, two digits |
\_ |
A Space |
\ |
A space (a space follows the backslash) |
\' |
Single quote |
\" |
Double Quote |
\\ |
A literal" \ " backslash character |
\x |
x , for any" x " not listed above |