关于Navicat for MySQL破解,以及连接数据库出现错误:1045-Access denied for user 'root'@'localhost'( using password yes)解决方法

出现这个问题的原因之一是权限的问题,也就是说你的电脑可能没有权限访问mysql数据库。

讲道理这种情况其实基本上不该遇到,因为我们在安装mysql之后,root其实是有最高权限的,而且很少会有人去修改root的权限。

这个问题的解决方法就是授权。授权命令大概是这样的:

grant all privileges on *.* to 'root'@'我电脑的ip地址' identified by '密码';

使用mysql -u root -p进入mysql

grant all privileges on *.* to 'root'@'192.168.0.103' identified by '123456';
如果你是本地登录的,那么:
grant all privileges on *.* to 'root'@'localhost' identified by '123456';
当然你也可以直接改成这样:
grant all privileges on *.* to 'root'@'%' identified by '123456';
就可以给所有ip都设定root登陆了。
如果授权成功,会有Query OK的提示。
然后:
flush privileges;
这个是刷新授权的意思,如果没有这句话,授权可能无法立刻生效。
exit;

猜你喜欢

转载自www.cnblogs.com/mollie-x/p/10460173.html