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 5.6 configure a secure encrypted password

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

Share

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

In shell scripts, you usually configure the plaintext password for the database, which is not secure. After MySQL version 5.6, you can configure a secure encrypted password file, which can then be used to connect to the database without entering a plaintext password.

Configure a secure encrypted password for local root users

[root@localhost] # mysql_config_editor set-- user=root-- password

Enter password:

Try to connect to the database

[root@localhost ~] # mysql

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

Your MySQL connection id is 179

Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c

Copyright (c) 2009-2016 Percona LLC and/or its affiliates

Copyright (c) 2000, 2016, 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.

Mysql > select user ()

+-+

| | user () |

+-+

| | root@localhost |

+-+

1 row in set (0.00 sec)

Mysql > exit

Bye

Go to the home directory, look at the encrypted password file, and you can see the garbled code inside.

[root@localhost ~] # cd

[root@localhost ~] # cat .mylogin.cnf

?

? # [root@localhost ~] # paired EQs SB??hH?XJ?-&?P?-/? a\ Swarm T SB??hH?XJ?-&?P?-/? | M5?

Configure the specified remote database connection user

[root@localhost] # mysql_config_editor set-login-path=remote-host=192.168.56.101-user=ss7-password

Enter password:

View a list of configured encrypted passwords

[root@localhost] # mysql_config_editor print-- all

[client]

User = root

Password = *

[remote]

User = ss7

Password = *

Host = 192.168.56.101

Try to connect to the database

[root@localhost] # mysql-- login-path=remote

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

Your MySQL connection id is 181

Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c

Copyright (c) 2009-2016 Percona LLC and/or its affiliates

Copyright (c) 2000, 2016, 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.

Mysql > select user ()

+-+

| | user () |

+-+

| | ss7@192.168.56.101 |

+-+

1 row in set (0.00 sec)

Mysql > exit

Bye

Connect root local users with the-- login-path option

[root@localhost] # mysql-- login-path=client

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

Your MySQL connection id is 182

Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c

Copyright (c) 2009-2016 Percona LLC and/or its affiliates

Copyright (c) 2000, 2016, 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.

Mysql > select user ()

+-+

| | user () |

+-+

| | root@localhost |

+-+

1 row in set (0.00 sec)

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