The prompt command can display information about the current user, database, time, and so on at the MySQL prompt
Copy Code code as follows:
Mysql-uroot-p--prompt= "\\u@\\h:\\d \\r:\\m:\\s>"
After the setting is successful:
Copy Code code as follows:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 5
Server Version:5.1.60-log Source Distribution
Copyright (c), the Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark the Oracle Corporation and/or its
Affiliates. Names may trademarks of their respective
Owners.
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Root@localhost: (None) 11:04:23>
Can also be configured in the MY.CNF configuration file:
Copy Code code as follows:
[MySQL]
Prompt=mysql (\\u@\\h:\\d) >
Default-character-set=utf8
Option Description:
Copy Code code 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 (a few, 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 Standard 12-hour time (1–12)
\s Semicolon
\s Seconds of the current time
\ t A tab character
\u www.jb51.net
Your Full User_name@host_name account name
\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 all "X" not listed above