修改my.ini文件,在文件[mysqld]节点下加入免密码登录:
skip-grant-tables
重启mysql 后登录mysql,修改密码new_pass
mysql -uroot
use mysql;
update user set password=password('123') where user='root' and host='localhost';
flush privileges;
再将my.ini文件中skip-grant-tables除去,重启mysql即可
若报验证密码:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
执行如下命令即可
SET PASSWORD = PASSWORD('new_pass');