安装mysql后本地无法连接问题-ERROR 1130 (HY000): "xxx.xx.xx.com" is not allowed to connect to this MySQL server

问题:安装mysql后本地无法连接问题

安装mysql后本地无法连接问题-ERROR 1130 (HY000): "xxx.xx.xx.com" is not allowed to connect to this MySQL server

ERROR 1130 (HY000): "xxx.xx.xx.com"  is not allowed to connect to this MySQL server

一、修改hosts文件

具体的映射文件的位置:c:/windows/system32/drivers/etc/hosts这个文件

安装mysql后本地无法连接问题-ERROR 1130 (HY000): "xxx.xx.xx.com" is not allowed to connect to this MySQL server

然而并没有解决问题

二、修my.ini文件
1)位置  在安装目录下  C:\Program Files\MySQL\MySQL Server 5.5
      my.ini文件中添加skip-grant-tables
安装mysql后本地无法连接问题-ERROR 1130 (HY000): "xxx.xx.xx.com" is not allowed to connect to this MySQL server
2)重启mysql

方法1:计算机右键---管理---服务和应用程序---服务--找到MySQL--点重启动

安装mysql后本地无法连接问题-ERROR 1130 (HY000): "xxx.xx.xx.com" is not allowed to connect to this MySQL server

方法2: 在cmd 命令行中打 net stop mysql /net start mysql来启停服务。

安装mysql后本地无法连接问题-ERROR 1130 (HY000): "xxx.xx.xx.com" is not allowed to connect to this MySQL server

3)命令行登录
安装mysql后本地无法连接问题-ERROR 1130 (HY000): "xxx.xx.xx.com" is not allowed to connect to this MySQL server
至此终于登录成功
三、授权

然后登陆到root账户,此时不需要输入密码就可以进入,然后grant授权

mysql> grant all privileges on *.* to [email protected]'localhost' identified by "123456";

如果此处报错  ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

只需要刷新权限就行,flush privileges;

然后再执行授权命令就行了。

最后记得在配置文件中删除 skip-grant-tables  参数,然后重启MySQL服务。

参考来源: https://www.cnblogs.com/rnckty/p/5577818.html


如果还不行就试一下下面这位博主写的

来源: https://blog.csdn.net/zyj405569395/article/details/53614356

1. 改表法。

可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"

mysql -u root -p

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>select host, user from user;

注:个人觉得不太适用!

2. 授权法。

例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH   PRIVILEGES;

如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH   PRIVILEGES;

如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器的dk数据库,并使用mypassword作为密码

GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH   PRIVILEGES;

我用的第一个方法,最后执行一个语句 mysql>FLUSH RIVILEGES 使修改生效.就可以了

另外一种方法,不过我没有亲自试过的,在csdn.net上找的,可以看一下.

在安装mysql的机器上运行:

1、d:/mysql/bin/>mysql   -h   localhost   -u   root  //这样应该可以进入MySQL服务器

2、mysql>GRANT   ALL   PRIVILEGES   ON   *.*   TO   'root'@'%'   WITH   GRANT   OPTION  //赋予任何主机访问数据的权限

3、mysql>FLUSH   PRIVILEGES  //修改生效

4、mysql>EXIT  //退出MySQL服务器

这样就可以在其它任何的主机上以root身份登录啦!