Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL implements password-less login (mysql_config_editor)

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

There is a business requirement to dump MySQL database data from a host, but you do not want the business staff to know the password of a specific MySQL user. You can use the mysql_config_editor command to achieve this.

First, the test environment

A machine IP is 192.168.3.171

The IP of machine B is 192.168.3.173

Intend to connect from B to A without a "password"

Database versions of An and B

(root@localhost) [(none)] > select version ()

+-+

| | version () |

+-+

| | 5.7.17-log |

+-+

1 row in set (0.00 sec) 2, create a test user on machine An and grant permissions

(root@localhost) [(none)] > create user gl@'192.168.3.173' identified by 'onlygl'

Query OK, 0 rows affected (0.00 sec)

(root@localhost) [(none)] > grant all on *. * to gl@'192.168.3.173'

Query OK, 0 rows affected (0. 01 sec) 3, execute the following command on machine B and enter the password of the gl user

Mysql_config_editor set-- login-path=gl-- host=192.168.3.171-- user=gl-- password 4. After executing the above command, you can find a hidden file .mylogin.cnf in the directory of home, as follows:

-rw- 1 root root 136 Feb 27 19:04. Mylogin.cnf five, check the contents of the file.

[root@mysqltest] # mysql_config_editor print-- all

[gl]

User = gl

Password = *

Host = 192.168.3.1716, log in

[root@mysqltest] # mysql-- login-path=gl

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 311

Server version: 5.7.17-log Mysqlma

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respective

Owners.

Type 'help;'or'\ h'for help. Type'\ c'to clear the current input statement. (gl@192.168.3.171) [(none)] > 7. If you don't want to use it, delete it with the following command

Mysql_config_editor remove-login-path= GL8, scope of application

Mysql

Mysqladmin

Mysqldump9, summary

1. It is obvious that after the user's password has been changed, the login-path needs to be recreated

two。 This feature is only supported in version 5.6.6 or above.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report