ERROR 1130(HY000)或ERROR 2003(HY000):将mysql从Windows连接到VMware上的ubuntu

时间:2015-06-18 12:55:35

标签: mysql linux

我尝试了很多方法,但都失败了。我想在Windows上通过VMware连接Linux上的MySQL。

  • VMware:11.1.0 build-2496824
  • Linux:Ubuntu 14.10
  • Windows:win 8.1 x64
  • MySQL版本

    • windws:5.6.24
    • Linux:5.5.43
  • IP

    • Windows:192.168.1.102
    • Linux:192.168.1.100

PS:Ping请求彼此接收数据包。

当我输入cmd时:

mysql -h 192.168.1.100 -u root_test -p

我确定我输入了正确的密码,但是mysql服务器返回" ERROR 1130(HY000):主机' 192.168.1.100'不允许连接到这个MySQL服务器" 或者" ERROR 2003(HY000):无法在' 192.168.1.100'上连接到MySQL服务器(10061)"

Proto   Recv-Q   Send-Q   Local Address      Foreign Address       State       PID/Program name
tcp          0        0   0.0.0.0:3306       0.0.0.0:*             LISTEN        -    



my.cnf:bind-address = 0.0.0.0

service iptables status
iptables: unrecognized service

select user,host from user;
+------------------+---------------+
| user             | host          |
+------------------+---------------+
| root             | 127.0.0.1     |
| root_test        | 192.168.1.102 |
| debian-sys-maint | localhost     |
| root             | localhost     |
+------------------+---------------+

show grants for 'root_test'@'192.168.1.102';

+-------------------------------------------------------------------------------------------------------------------------------+
| Grants for root_test@192.168.1.102                                                                                            |
+-------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root_test'@'192.168.1.102' IDENTIFIED BY PASSWORD 'MD5-PWD'                                   |

+-------------------------------------------------------------------------------------------------------------------------------+

更新

我最终通过在Windows上将IPv4属性Obtain an IP address automatically更改为use the following IP address来解决这个问题。

here

PS:VMware的互联网设置为Bridged

非常感谢@ s3v3n和@Drew Pierce,你很友善。谢谢。

1 个答案:

答案 0 :(得分:1)

1)更改my.conf(无论你调用mysql conf文件)。并将bind-address设置为0.0.0.0,因为它是概率127.0.0.1

2)停止/重启mysql守护进程

Connections now are not limited to those from localhost. The default is localhost for obvious security reason until dev guy tweaks it

3)授予冲洗

4)防火墙

祝你好运!

修改

显示在某些环境中设置用户/获取

所需的信息
  

主要是它显示了sqlyog如何能够将您带入您看到的主机名或   由mysql守护进程知道(不管你认为你的IP是什么   地址是)。

所以我坐在这里认为我的工作站上的外部IP地址是188.188.188.188而且我在我的服务器中继续使用它来创建用户和授权,并且它最终无法进入mysql。

我也在寻求严密的安全保障。

在aws ec-2或你的虚拟机环境中创建一个实例。

我的公共dns = ec2-23-21-7-136.compute-1.amazonaws.com

只有端口22打开(ssh)

mysql被烘焙并运行,对外界视而不见。

运行sqlyog进入。它炸弹。好。可见here

ssh / putty进入或坐在服务器上(我在新加坡,而不是坐在) 在linux提示符下我进入了mysql

所以现在我处于一个mysql提示符(不是操作系统,我知道你知道其他人可能不会:>)

mysql> select user,host from mysql.user;
+------------------+------------------------+
| user             | host                   |
+------------------+------------------------+
| root             | 127.0.0.1              |
| foo_user         | w.x.y.z                |
+------------------+------------------------+
2 rows in set (0.00 sec)

进入vm并打开端口3306以获取入站0.0.0.0/0(任何地方)

再次尝试使用sqlyog连接root。

炸弹。好。炸弹给了我们很好的信息。

可见here

我知道mysql认为我应该是谁,很高兴root无法进入

'根' @' xxxx.yyyy.comcastbusiness.net'

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| foo                |
| mysql              |
| performance_schema |
| phpmyadmin         |
| test               |
+--------------------+
6 rows in set (0.00 sec)

所以我创建了用户

CREATE USER 'fred7'@'xxxx.yyyy.comcastbusiness.net' IDENTIFIED BY 'bonehead7';

GRANT ALL PRIVILEGES ON test.* TO 'fred7'@'xxxx.yyyy.comcastbusiness.net';

对于那些疯狂的通配符,让你的安全性不那么紧张

mysql> select user,host from mysql.user;
+------------------+-------------------------------+
| user             | host                          |
+------------------+-------------------------------+
| root             | 127.0.0.1                     |
| foo_user         | w.x.y.z                       |
| fred7            | xxxx.yyyy.comcastbusiness.net |
+------------------+-------------------------------+

再次尝试sqlyog连接,这次是user = fred7密码= bonehead7 好。

我在。

可见here

并且有很多欢乐(至少对我而言)