The MySQL console program's prompt prompt string setting _mysql

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.