mysql custom prompt

Detailed explanation of the usage of mysql prompt

--prompt=name After we log in to the mysql database, the prompt of mysql is just a very simple content mysql> without any other information.

Through --prompt=name, you can customize the prompt information, and display the login host address, login user name, current time, current database, etc. by configuration.

The parameters are as follows:

Option  Description
\c  A counter that increments for each statement 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 (Jan, Feb, …)
\o  The current month in numeric format
\P  am/pm
\p The current TCP/IP port or socket file
\R  The current time, in 24-hour military time (0–23)
\r  The current time, standard 12-hour time (1–12)
\S  Semicolon
\s  Seconds of the current time
\t  A tab character
\U   

\u Your user name
\v  The server version
\w  The current day of 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

Method 1: Modify directly at the mysql prompt, which only takes effect for the current session.

mysql>\R  mysql(\d)>

mysql(yoy)>use test;
Database changed
mysql(test)>

 

Method 2: Modify it under [mysql] in the my.cnf configuration file, and it will take effect permanently.

[mysql]
prompt="\\u@\\h :\\d\\r:\\m:\\s>"

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325813611&siteId=291194637