MySQL displays the name of the connected database

Source: Internet
Author: User

MySQL displays the name of the connected database

By default, MySQL does not display the name of the connected database when using 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>

You can display the name of the connected database in the following ways:
[Root @ hank-yoon 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) 2000,201 5, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be 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)>

To display the name and time of the connected database:
[Root @ hank-yoon 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) 2000,201 5, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be 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>

You can also add it to the my. cnf configuration file, but you need to restart the database. If you need to restart the production database, you can not just restart it. Therefore, you can add it during connection!
[Mysql]
Default-character-set = utf8
Prompt = \ u (\ d) \ R: \ m: \ s> \

This article permanently updates the link address:

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.