MySQL prompt a particularly handy command _mysql

Source: Internet
Author: User

I guess everyone in the command line operation MySQL will be very worried about the operation of the database now, at least I have struggled, you may say that I do not know the command, yes this is indeed possible.
But today we are introducing a good command--prompt

Copy Code code as follows:

[Root@fsailing1 ~]# mysql-uroot-p--prompt= "\\u@\\h:\\d \\r:\\m:\\s>"
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 378
Server version:5.0.95 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) 08:23:32>use test;
Reading table information for completion of table and column names
You can turn off the feature to get a quicker startup with-a

Database changed
Root@localhost:test 08:23:44>exit;


The advantage of doing this is to make it easier and quicker for all of us to manipulate the database.

You can also configure it in the MY.CNF configuration file:

Copy Code code as follows:

[MySQL]
Prompt=mysql (\\u@\\h:\\d) >

Default-character-set=utf8


Copy Code code as follows:

[Root@fsailing1 ~]# vim/etc/my.cnf
[root@fsailing1 ~]# Service mysqld Restart
Stop MySQL: [OK]
Start MySQL: [OK]
[Root@fsailing1 ~]# Mysql-uroot-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server version:5.0.95 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.

MySQL (root@localhost: (none)) >use test;
Reading table information for completion of table and column names
You can turn off the feature to get a quicker startup with-a

Database changed
MySQL (root@localhost:test) >


here also give some of the necessary options for your reference.
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

\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 no " 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.