关于用Windows安装WAMP后无法登陆mysql问题的解决办法
1、 把\Bitnami\wampstack-7.3.19-0\apps\phpmyadmin\htdocs目录下config.inc.php中的cfg[′Servers′][cfg['Servers'][cfg[′Servers′][i][‘AllowNoPassword’] = false;改为cfg[′Servers′][cfg['Servers'][cfg[′Servers′][i][‘AllowNoPassword’] = true;
2、 在my.cnf 文件中添加skip-grant-tables,然后在服务中停止MySQL服务或者用net stop mysql
3、用管理员权限打开cmd执行mysqld --skip-grant-tables --shared-memory
4、 在另一个cmd窗口直接mysql 登录,此时不需要填写密码。
5、执行一下sql语句(如直接执行不成功,需要在语句后面加\g)
use mysql
update user set authentication_string=’’ where user=’root’ 清空root用户密码。(清空后密码为空)
ALTER user ‘root’@‘localhost’ IDENTIFIED BY ‘root’(当authentication_string不为空时执行后密码改为“root“)
最后再执行一遍flush PRIVILEGES刷新权限(当authentication_string为空时密码为空,不为空时为ALTER user ‘root’@‘localhost’ IDENTIFIED BY 'root’更改的密码)
6、 注释掉skip-grant-tables,重启mysql
7、 mysql -uroot 无密码登录到root模式。
NOTE:此方法只针对8.0.0之后mysql版本有效,系统环境为win10
本文提供了一种解决在Windows环境下使用WAMP时遇到的MySQL登录难题的方法,包括修改config.inc.php文件、利用skip-grant-tables跳过权限检查、重置root用户密码等步骤,适用于MySQL 8.0.0及以后版本。
1万+

被折叠的 条评论
为什么被折叠?



