MySQL's mysql_config_editor use

Source: Internet
Author: User

Mysql_config_editor/login-path Use

First, the design reason explanation:

Login-path is a new feature that MySQL5.6 started to support. By using the Mysql_config_editor tool, the authentication information of the login MySQL service is saved in the. mylogin.cnf file (default is in the user home directory),
After that, the MySQL client tool can connect to MySQL by reading the encrypted file, avoiding the need to repeatedly enter login information to avoid sensitive information exposure.

Second, tool use Help

Mysql_config_editor Use Help:

2.1 Configuration:
mysql_config_editor set --login-path=test --user=test_user  --host=127.0.0.1 --port=3306 --password或者mysql_config_editor set -G test001 -uroot -p -hlocalhost -P3306 -S /tmp/mysql.sockmysql_config_editor set -G test001 -uroot -p

Which method to use, specifically according to the MY.CNF configuration file in the MySQL login parameters and MySQL database in the specific authorization to set

Where configurable items are described:

-h,–host=name 添加host到登陆文件中-G,–login-path=name 在登录文件中为login path添加名字(默认为client)-p,–password 在登陆文件中添加密码(该密码会被mysql_config_editor自动加密)-u,–user 添加用户名到登陆文件中-S,–socket=name 添加sock文件路径到登陆文件中-P,–port=name 添加登陆端口到登陆文件中
2.2. Example Demonstration

Here is an example demo with the MySQL root login account:
Many of my classmates landed on MySQL like this.

[[email protected] ~]# mysql -uroot -p‘wujianwei‘工具使用[[email protected] ~]# mysql_config_editor set --login-path=test001 --user=root  

An encrypted binary file is generated at the same time as the user's home directory

At this time login MySQL Demo:


Or the following ways are possible:

[[email protected] ~]# mysql_config_editor set -G test001 -uroot -hlocalhost -P3306 -S /tmp/mysql.sock -pEnter password: [[email protected] ~]# ll .mylogin.cnf -rw------- 1 root root 192 Jul 21 11:05 .mylogin.cnf
2.3 Display configuration:
mysql_config_editor print --login-path=test #显示执行的login-path配置mysql_config_editor print --all             #显示所有的login-path信息

Example Demo:

[[email protected] ~]# mysql_config_editor print --login-path=test001[test001]user = rootpassword = *****host = localhostsocket = /tmp/mysql.sockport = 3306

To view the specified login name login information:

[[email protected] ~]# mysql_config_editor print -Gtest001[test001]user = rootpassword = *****host = localhostsocket = /tmp/mysql.sockport = 3306
[[email protected] ~]# mysql_config_editor set -G test002 -uroot -hlocalhost -P3306 -S /tmp/mysql.sock -pEnter password: [[email protected] ~]# mysql_config_editor print -Gtest002[test002]user = rootpassword = *****host = localhostsocket = /tmp/mysql.sockport = 3306

To view the login information for all login names:

[[email protected] ~]# mysql_config_editor print --all[test001]user = rootpassword = *****host = localhostsocket = /tmp/mysql.sockport = 3306[test002]user = rootpassword = *****host = localhostsocket = /tmp/mysql.sockport = 3306
2.4 Delete configuration:

Mysql_config_editor Remove--login-path=test

[[email protected] ~]# mysql_config_editor remove --login-path=test002或者是:[[email protected] ~]# mysql_config_editor remove -Gtest002[[email protected] ~]# mysql_config_editor print --all[test001]user = rootpassword = *****host = localhostsocket = /tmp/mysql.sockport = 3306

To reset the configuration:
Mysql_config_editor Reset--login-path=test

2.5, using the default login mode
[[email protected] ~]#mysql_config_editor set -uroot -p[[email protected] ~]# mysql_config_editor print --all[test001]user = rootpassword = *****host = localhostsocket = /tmp/mysql.sockport = 3306[client]user = rootpassword = *****

Landing:

2.6 Description of the items which can be deleted

-h,–host=name adding the host to the login file
-g,–login-path=name Name of Login path in the login file (default to client)
-p,–password add a password to the login file (the password will be automatically encrypted by Mysql_config_editor)
-u,–user add user name to log in file
-s,–socket=name Add sock file path to the login file
-p,–port=name Add the login port to the login file

2.7. Remotely log on to other machines MySQL

To log in to another host, another port, or add additional parameters, add it directly after the above command

shell>mysql --login-path=test  -h host1 -P port1 #登录host1:poet1上的MySQLshell>mysql --login-path=test  -h host1 -P port1 test_db #登录host1:poet1上的MySQL中的test_db库

Reference Address:
Http://dev.mysql.com/doc/refman/5.7/en/mysql-config-editor.html

MySQL's mysql_config_editor use

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.