将apache监听的端口由80改为8888,mysql无法本地登录,报错如下:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
但是使用另外一台电脑可以使用:mysql -uroot -h xxxx -p登录成功
原因如下:
mysql中一个用户名为空的访问本地权限的字段,所有登陆时优先匹配了这一条,就无法登陆了。
select user,host from mysql.user;
#删除用户即可
drop user ''@localhost;
flush privileges;
到此就能正常访问数据库了!!
感谢tshangshi的博客:https://blog.csdn.net/tshangshi/article/details/52244394#commentBox完美解决我的问题!