MySQL5.7 reset root password

   If MySQL is running, kill it first: killall -TERM mysqld.
Run mysqld_safe --skip-grant-tables &
if you don't want to be connected remotely at this time: mysqld_safe --skip-grant-tables --skip-networking &

use mysql connection server
to change the password: update mysql.user set authentication_string=password('123qwe ') where user='root' and Host = 'localhost';
*It is important to note that there is no Password field in the user table under the new version of mysql database,

but the encrypted user password is stored in the authentication_string field

mysql > flush privileges;
mysql> quit;

modification is completed. Restart
killall -TERM mysqld.
mysqld_safe &
Then mysql can be connected,

but operation seems to be incomplete at this time, and alter user is required...
alter user 'root'@'localhost' identified by '123';
the net text says that Jiangzi can also: set password for ' root'@'localhost'



cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql


reboot and try

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326429381&siteId=291194637