How to connect to a MySQL server running in a virtual machine

I have MySQL Server 5.5.32 running on Ubuntu 12.04. Ubuntu runs in a virtual machine. The host platform is Windows 7. How can I connect to Ubuntu MySQL from Windows?

I have done the following:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES; 

Running a show grant for root; displays this:

 +-------------------------------------------------------------+ | Grants for root@% | +-------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION | +-------------------------------------------------------------+ 

But when I try to connect to this server from SQLYog running on Windows, I get Error 2003 Cannot connect to mysql server on '192.168.xxx.xxx' error message.

The IP channel served to SQLYog received it from ifconfig . Comes with an optional add-on.

 inet addr:192.168.226.xxx Bcast:192.168.226.yyy 

Is the wrong address used or are these problems provided? Please advice.

+8
mysql virtual-machine
source share
5 answers

The problem is that (possibly) your mysql is bound to 127.0.0.1 instead of 0.0.0.0 .

You should change the binding in /etc/mysql/my.cnf to 0.0.0.0

bind-address = 0.0.0.0

And then restart mysql, of course.

+14
source share

Error No. 2003: Can't connect to MySQL server on 'localhost' (or some other host) Message Error No. 2003: Can't connect to MySQL server on 'localhost' (or some other host)

simply means that the connection is not possible for one of the following (or similar) reasons:

  • MySQL server does not work on the specified host

  • Connecting to a MySQL server is prohibited using TCP-IP. Check the skip-networking setting in the MySQL configuration file (my.ini on Windows, my.cnf on Unix / Linux). It should be commented as "# skip-networking". If it is not commented out, do it and restart the MySQL server for the changes to take effect. SQLyog needs to connect using TCP-IP.

  • Some network problems interfere with the connection. This could be an incorrect network configuration or a firewall problem. Sometimes we find that some firewalls block TCP-IP connections, even if they claim to be disabled. More often than not, this will help remove and reinstall the firewall.

  • When trying to connect to a MySQL server from a provider, this error message often indicates that a direct connection to MySQL is blocked. Then you should use HTTP tunneling or SSH tunneling.

+1
source share

I think the problem is with the settings of the Network adapter in the settings of your virtual machine

Do this in the virtual machine settings.

Virtual machine settings → Network adapter settings → Select bridges

The VM will connect to the physical network when the network connection is in bridge mode.

Try pinging the VM host on your Windows computer after changing the network connection to with the bridge .

If the virtual machine is pinging on your Windows machine, it will work.

+1
source share

In new versions of MySQL, instead of skip-networking, by default now you only need to listen to localhost bind-address = 127.0.0.1

So, you need to add your computer IP address or just comment on it if you are not worried about security issues.

+1
source share

Error No. 2003: Unable to connect to MySQL server on page 192.168.xx

simply means that the connection is not possible for one of the following (or similar) reasons:

  • MySQL server does not work on the specified host

  • Connecting to a MySQL server is prohibited using TCP-IP. Check the skip-networking setting in the MySQL configuration file (my.ini on Windows, my.cnf on Unix / Linux). It should be commented as "# skip-networking". If it is not commented out, do it and restart the MySQL server for the changes to take effect. SQLyog needs to connect using TCP-IP.

  • Make sure you can connect to the MySQL port using telnet

    C: \ telnet username / IP_address port

0
source share

All Articles