第一步:输入 mysql -u root -p  然后回车

输入密码

第二步:输入 use mysql;

第三步:输入update user set authentication_string='' where user='root';将authentication_string置空

第四步:输入select user,host from user;

mysql8.0 修改数据库root密码-LMLPHP

第五步:输入alter user 'root'@'%' identified by '新密码';(注意:我的root host是%,如果user的host是localhost,就需要改成alter user 'root'@'localhost' identified by '新密码';)

09-06 04:04