Step1
在[mysqld]后添加skip-grant-tables(登录时跳过权限检查)
然后重启MySQL,登录mysql,输入mysql –uroot –p;直接回车(Enter)
输入:set password for ‘root’@‘localhost’=password(‘123456’);
如果报:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
输入:flush privileges;
再次输入:set password for ‘root’@‘localhost’=password(‘123456’);
为避免麻烦,再次设置远程访问
输入:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'Admin123@qwe' WITH GRANT OPTION;
再次输入:flush privileges;
退出:exit
再把my.ini的skip-grant-tables删除或者注释掉
最后重启MySQL即可