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.7.18 what should be done if the password is forgotten or expired?

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

Share

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

This article mainly tells you how to solve the problem of MySQL 5.7.18 password forgetting or expiration. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here, so let's go straight to the topic. I hope that how to solve the problem of MySQL 5.7.18 password forgetting or expiration can bring you some practical help.

First, forget the password to solve [root@linux-node2 ~] # / etc/init.d/mysqld stop [root@linux-node2 ~] # mysqld_safe-- skip-grant-tables & [root@linux-node2 ~] # mysql-pmysql > update mysql.user set authentication_string=password ('123456') where user='root' and Host = 'localhost' # A special reminder is that there is no Password field in the user table under the new version of mysql database. # instead, the encrypted user password is stored in the authentication_string field mysql > flush privileges;mysql > quit; [root@linux-node2 ~] # / etc/init.d/mysqld restart# and then mysql can be connected, but at this time the operation seems to be incomplete and still requires alter user. Mysql > show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql > alter user 'root'@'localhost' identified by' 123456 question OK, 0 rows affected (0.01 sec) mysql > quit;Bye [root@linux-node3 mysql] # / etc/init.d/mysqld restartShutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS! [root@linux-node3 mysql] # mysql-uroot-p123456mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 3Server version: 5.7.18-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, 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 respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > show databases +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sys | +-+ II. Solution to password expiration problem 1. Problem phenomenon [root@linux-node2 mysql] # mysql-uroot-pEnter password: ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.2, modify the configuration file / etc/my.cnf [root@linux-node2 mysql] # vim / etc/my.cnf # add skip-grant-tables under [mysqld] Skip authorization table login [client] port = 3306 socket = / data/mysql/ mysql.sock [MySQL] no-auto-rehash [mysqld] user = mysqlport = 3306 socket = / data/mysql/mysql.sock datadir = / data/mysql/datalog-bin = / data/mysql/mysql-binserver-id = 6skip-grant-tables [root@linux-node2 mysql] # / etc/init.d/mysqld restartShutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS! 3. Log in to mysql [root@linux-node2 mysql] # mysqlWelcome to the MariaDB monitor. Commands end with; or\ g.Your MySQL connection id is 4Server version: 5.7.18-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MySQL [(none)] > use mysql;Database changedMySQL [mysql] > update user set password_expired='N' where user='root';Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0MySQL [mysql] > flush privileges;Query OK, 0 rows affected (0.01 sec) MySQL [mysql] > quit Bye4, remove and skip authorization table login, and restart login [root@linux-node2 mysql] # vim / etc/my.cnf [root@linux-node2 mysql] # / etc/init.d/mysqld restartShutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS! [root@linux-node2 mysql] # mysql-uroot-p123456Welcome to the MariaDB monitor. Commands end with; or\ g.Your MySQL connection id is 3Server version: 5.7.18-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MySQL [(none)] > quit

Bye

MySQL 5.7.18 password forgotten or expired how to solve the first to tell you here, for other related issues you want to know can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

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