MySQL 5.7.18 forgot password and password expiration resolved

Source: Internet
Author: User

First, forget the password to solve
[[email protected] ~]#/etc/init.d/mysqld stop[[email protected] ~]# mysqld_safe--skip-grant-tables &[ [email protected] ~]# mysql-pmysql> update mysql.user set Authentication_string=password (' 123456 ') where user= ' Root ' and Host = ' localhost '; #特别提醒注意的一点是, there is no password field in the user table in the new MySQL database, but the encrypted user password is stored in the Authentication_ String field mysql> flush privileges;mysql> quit; [[email protected] ~]#/etc/init.d/mysqld restart# then MySQL can connect, but at this time the operation seems to be incomplete, but also alter user...mysql> show Databases ERROR 1820 (HY000): Must reset your password using ALTER USER statement before executing this statement.mysql> alte R user ' root ' @ ' localhost ' identified by ' 123456 '; Query OK, 0 rows affected (0.01 sec) mysql> quit; Bye[[email protected] mysql]#/etc/init.d/mysqld restartshutting down MySQL. success! Starting MySQL. success! [[email protected] mysql]# mysql-uroot-p123456mysql: [Warning] Using a password on the command line interface can b E 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), Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names 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 |+--------------------+
Second, the password expires the problem solves 1, the problem phenomenon
[[email protected] 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
[[email protected] mysql]# vim /etc/my.cnf #在[mysqld]下增加skip-grant-tables,跳过授权表登录[client]    port        = 3306     socket      = /data/mysql/mysql.sock[mysql]no-auto-rehash[mysqld]    user = mysqlport        = 3306     socket      = /data/mysql/mysql.sock     datadir     
3. Log in to MySQL
[[email protected] 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;Bye
4, remove the Skip authorization form login, and restart the login
[[email protected] mysql]# vim /etc/my.cnf[[email protected] mysql]# /etc/init.d/mysqld restartShutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS! [[email protected] 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 forgot password and password expiration resolved

Related Article

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.