如何从VM访问主机MySQL?

时间:2019-03-09 18:29:18

标签: mysql vmware

主机:

  • Windows 10
  • ip = 192.168.0.142

虚拟机

  • Centos 7
  • ip = 192.168.0.127

我的问题是:

我希望虚拟机访问Windows上的MySQL数据库。我试图通过在my.cnf文件中添加bind-address=192.168.0.142来绑定地址。重新启动mysql服务后,它返回错误:Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details。我忘了配置什么吗?

mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: deactivating (final-sigterm) (Result: exit-code) since Sat 2019-03-09 13:03:58 EST; 1min 24s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 45995 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
  Process: 45971 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 44232 (code=exited, status=0/SUCCESS)
    Tasks: 4
   CGroup: /system.slice/mysqld.service
           └─45998 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Mar 09 13:05:20 localhost.localdomain systemd[1]: Starting MySQL Server...
Mar 09 13:05:21 localhost.localdomain systemd[1]: mysqld.service: control process exited, code=exited status=1

我所做的事情:

  • 我的主机可以ping通虚拟机,但是虚拟机无法ping通主机。
  • 虚拟机上的防火墙已关闭,但iptables已打开。这是iptables列表。
Chain INPUT (policy ACCEPT)

target     prot opt source               destination  
    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:opsession-prxy

ACCEPT     tcp  --  192.168.0.142        anywhere             tcp dpt:opsession-prxy

ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:opsession-prxy

ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination
  • 我已将虚拟机网络设置为桥接。
  • 当我将绑定地址更改为127.0.0.1时没有问题,这意味着连接到虚拟机的MySQL。

0 个答案:

没有答案