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: