MySQL5.7和8.0

方法一

update mysql.user set authentication_string=password('123456') where host='localhost' and user='root';

方法二

skip-grant-tables
mysql -S /var/lib/mysql/mysql.sock
flush privileges;
alter user 'root'@'localhost' identified by '123456';

MySQL5.6

update mysql.user set password=password('123456') where host='localhost' and user='root';

通过启动脚本的方法

service mysqld restart --init-file=/usr/local/mysql57/init.sq
bin/mysqld_safe --defaults-file=my.cnf --init-file=/usr/local/mysql57/init.sql &
init.sql内容:alter user 'root'@'localhost' identified by '123456';

本文由 建站网 撰写创作,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。

还不快抢沙发

添加新评论