MySQL5.7 forgot root password, how to break?
Close the service
# kill -0 $mysql_pid# kill $mysql_pid
Free-secret Boot
# /usr/local/mysql57/bin/mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables &[1] 166882017-12-08T10:32:24.764472Z mysqld_safe Logging to ‘/data/database/mysql/host-30-0-0-196.err‘.2017-12-08T10:32:24.901997Z mysqld_safe Starting mysqld daemon with databases from /data/database/mysql
Change the code!
# /usr/local/mysql57/bin/mysql -S /tmp/mysql.sock mysql> update mysql.user set authentication_string=password(‘4a68a3c809c38e31‘) where user=‘root‘ ; Query OK, 1 row affected, 1 warning (0.01 sec)Rows matched: 1 Changed: 1 Warnings: 1mysql> quitBye
Restart
# /usr/local/mysql57/bin/mysqladmin -S /tmp/mysql3308.sock shutdown 2017-12-08T10:33:02.360399Z mysqld_safe mysqld from pid file /data/database/mysql/host-30-0-0-196.pid ended[1]+ Done 阿/usr/local/mysql57/bin/mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables# /usr/local/mysql57/bin/mysqld_safe --defaults-file=/etc/my.cnf
We have to change it again.
You must reset your password using ALTER USER statement before executing this statement.mysql> alter user [email protected] identified by ‘4a68a3c809c38e31‘;Query OK, 0 rows affected (0.01 sec)
OK
MySQL5.7 forgot root password, how to break?