When I use mysqld_safe to start my MySQL in CentOS7:
[root@localhost bin]# mysqld_safe --skip-grant-tables & [1] 32586 [root@localhost bin]# 2017-09-07T13:29:36.423040Z mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'. 2017-09-07T13:29:36.456574Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
It get stuck in the mysqld_safe Starting mysqld daemon
.
I find the SO, do not find this post, and some similar, but is not stuck, they report error directly.
MySQL version is 5.7.19
My requirement is change the user root
‘s password.
Advertisement
Answer
At last, I find if change the mysql version greater than 5.7’s password, we should not use the outdated method.
The correct method:
In the mysql config file
/etc/my.cnf
, addskip-grant-tables
in the[mysqld]
.Restart mysql (
/etc/init.d/mysqld restart
)Start mysql (
type mysql directly
)Change the password of user(
root
)ALTER USER 'root'@'localhost'IDENTIFIED BY 'newpassword'
Exit mysql and delete the
skip-grant-tables
in/etc/my.cnf
Then you can use
mysql -u root -p
to login the mysql now.