Author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/
The command line after I log on to MySQL looks like this:
Warmbupt @ pchuang:/Windows/mycode/SS $ mysql-u root-ppassw0rd
Welcome to the MySQL monitor. commands end with; or/g.
Your MySQL connection ID is 37
Server version: 5.1.37-1ubuntu5. 1 (UBUNTU)
Type 'help; 'or'/H' for help. type'/C' to clear the current input statement.
Mysql>
Through a series of transformations, we can get a command line prompt that is more user-friendly.
We try to display the username, host name, and database name in use:
Set the environment variable in the shell command line:
Export mysql_ps1 = "/u @/H [/d]>"
Where
- /U-username Username
- /H-hostname Host Name
- /D-current MySQL Database Current Database
Of course, you can write this command to bashrc and then use it in Bash to get such a command line prompt. Or you can set it in the MySQL configuration file/etc/My. CNF or. My. CNF:
prompt=//u@//h [//d]>//_
In addition, you can also set the following in MySQL:
Prompt/u @/H [/d]>
When you want to restore the original data, you can type prompt in MySQL to return to the regression (back to the settings outside MySQL, if you write in bashrc, it will return to the setting state in bashrc ).
Variable table attached:
Generic variables:
- /S displays semicolon
- /'Displays single quote
- /"Displays double quote
- /V displays server version
- /P displays Port
- // Displays backslash
- /N displays newline
- /T displays Tab
- /Displays space (there is a space after /)
- /D displays default database
- /H displays default host
- /_ Displays space (there is a underscore after /)
- /C displays a MySQL statement counter. keeps increasing as you type commands.
- /U displays Username
- /U displays username @ hostname accountname
Date related variables:
- /D displays full current date (as shown in the above example)
- /W displays 3 letter day of the week (e.g. Mon)
- /Y displays the two digit year
- /Y displays the four digit year
- /O displays month in number
- /O displays 3 letter month (e.g. Jan)
- /R displays current time in 24 hr format
- /R displays current time in 12 hour format
- /M Displays the Minutes
- /S displays the seconds
- /P displays am or PM
Author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/