mysql8.0 修改数据库root密码
第一步:输入
mysql -u root -p
然后回车,输入密码
第二步:输入
use mysql;
第三步:输入
update user set authentication_string='' where user='root';
将authentication_string置空
第四步:输入
select user,host from user;
第五步:输入
alter user 'root'@'%' identified by '新密码';
或者
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123';
(注意:我的root host是%,如果user的host是localhost,就需要改成 alter user 'root'@'localhost' identified by '新密码';)