Method 1 for Automatic Logon of MYSQL command line tool. It is required that the mysql (command-line tool) terminal be often used to connect to the mysql db service in the linux environment.
The general syntax is as follows: mysql [options] db_name important option parameters include: -- database = db_name,-D db_name -- host = host_name, -h host_name -- password [= password],-p [password] -- port = port_num,-P port_num -- user = user_name,-u user_name The following is a call example: mysql-h10.6.28.90-uroot-Dtest-P3306-p
Every time you log on, you need to enter so many parameters that seriously affect productivity. Is there a simple way? 2. solution: In the working directory of the linux operating system, create a file under "/data/your user name" or "/home/your user name. my. cnf file. The configuration content is as follows:
[client]user=rootport=3306host=10.6.28.90database=testdatabase=testpassword=MYsql3306
Finally, remove all other file attributes of. my. cnf and retain only the primary-readable attributes. See the following reference.
mark@PAY:~> cat .my.cnf[client]user=rootport=3306host=10.6.28.90database=testpassword=MYsql3306mark@PAY:~> ls -al .my.cnf-r-------- 1 mark users 78 2013-08-13 10:52 .my.cnf
3. The test result is now directly input mysql in the working directory to directly connect to the specified database of the specified database service, and there is no need to worry about entering login information such as passwords. 4. Working Principle
When the mysql command line is started, the configuration file Default options are read from the following files in the given order:/etc/my. cnf/etc/mysql/my. cnf/usr/local/mysql/etc/my. cnf ~ /. My. cnf this command can be used to run mysql; mysql/bin/my_print_defaults
View. If the preceding directory contains files, the configuration of the last file overwrites the configuration of the previous file. Therefore, the priority level is the lowest ~ The configuration of the/. my. cnf file is used and the logon is successful.