MySQL Displays the database name of the connection

Source: Internet
Author: User
Tags reserved

By default, MySQL does not display the connected library name when use DatabaseName!

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| Hank |
| MySQL |
| Performance_schema |
| Sakila |
| Test |
| Yoon |
+--------------------+
7 Rows in Set (0.00 sec)


Mysql> Use Yoon;
Database changed
Mysql>

The database name that displays the connection can be implemented in the following ways:
[Email protected] tmp]#MySQL--prompt= "\u (\d) >"

Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 29
Server Version:5.6.26-log Source Distribution


Copyright (c), Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.


Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.


Root ((none)) >use Yoon;
Database changed
Root (Yoon) >

If you want to display the name and time of the connected library:
[Email protected] tmp]#MySQL--prompt= "\u (\d) \r:\m:\s >"

Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 30
Server Version:5.6.26-log Source Distribution


Copyright (c), Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.


Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.


Root ((none)) 15:20:08 >use Yoon
Database changed
Root (yoon) 15:20:16 >

can also be added in the my.cnf configuration file, but need to restart the DB, production library, it is not easy to restart, so when connected to add it!
[MySQL]
Default-character-set = UTF8
prompt = \\u (\\d) \\r:\\m:\\s > \

MySQL Displays the database name of the connection

Related Article

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.