I hope it's not the end, it's the beginning, I hope it's not the end
Today in the course of MySQL practice, suddenly found that after logging on to MySQL, the command line can not display the user name and host information, at the same time, want to see the database information also need to see the Select datebase () command to view, especially inconvenient, so the special view of MySQL related information, How can I display this information every time I log in through a client? In fact, the relevant settings of MySQL in the configuration file my.cnf can be set. So go to see the my.cnf file, before the use, no careful look. MY.CNF configuration file in two parts: [Client] and [Mysqld], the former is the configuration parameters of the client, the latter is the configuration parameters of the server, since the problem is: the client login MySQL service display relevant information, then the configuration should be in [client], then how should be set? Please see the answers below.
Lab Environment:
[Email protected] ~]# cat/etc/redhat-release CentOS release 6.5 (Final)
MySQL version: Server version:5.6.33-log mysql Community server (GPL)
By default , the database name of the current connection is not displayed after you connect to the MySQL library. such as,
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/89/D1/wKiom1gdu7eDOCtBAAGM6VTNZq4709.png-wh_500x0-wm_3 -wmp_4-s_2876509457.png "title=" 1 2016-11-05_184627.png "alt=" Wkiom1gdu7edoctbaagm6vtnzq4709.png-wh_50 "/>
In this way, the current user and hostname as well as the current database information are not visible every time after landing MySQL, which brings inconvenience to maintenance work. In fact, after logging on to MySQL, you can set the MySQL configuration file to display the above information. Method: Modify the Prompt option in [mysqld] in the MySQL configuration file/etc/my.cnf. The process is as follows:
(1) Open the MySQL configuration file: Edit /etc/my.cnf Add the following line of red color as follows
[Email protected] ~]# VI/ETC/MY.CNF
[Client]
Port = 3306
Socket =/tmp/mysql.sock
prompt= "\\[email protected]\\h:\\d>"
#character_set_server = UTF8
#character_set_client = UTF8
[Mysqld] Note: Restart after setting MySQL Service. \u represents the user name , \h represents the host name, and \d represents the current database.
Formatting can add related symbols such as [] etc.
(2) restart MySQL Service
[Email protected] ~]#/etc/init.d/mysql restart
Shutting down MySQL ... success!
Starting MySQL ......... ..... success!
(3) Connection test
[Email protected] ~]# Mysql-uroot-penter password:welcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.6.33-log mysql Community Server (GPL) Copyright (c) +, Oracle and/or Itsaffiliates. All rights reserved. Oracle is a registered trademark of oraclecorporation and/or itsaffiliates. Other names trademarks of Theirrespectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clearthe the current input statement.
[email protected]:(None) >use MySQL
Reading table information for completion of Tableand column names
Can turn off this feature to get a quickerstartup with-a
Database changed
[email protected]:mysql>use Test
Reading table information for completion of Tableand column names
Can turn off this feature to get a quickerstartup with-a
Database changed
[Email protected]:test>
Description
For changes in profile/etc/my.cnf, the prompt option can be viewed through the Help document
--prompt more settings to view MySQL command help
Thank you for reading, the road to technical learning is still very long, willing to grow with you!
This article is from the "Persistent It Man" blog, please be sure to keep this source http://it3246.blog.51cto.com/7479386/1869838
MySQL mysql:prompt settings-login MySQL display user name and host and current database