Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to a MySQL server running on a Virtual Machine

I have a MySQL Server 5.5.32 running on Ubuntu 12.04. Ubuntu is being run on VM. Host platform is Windows 7. How can I connect with the Ubuntu's MySQL from Windows?

I have done the following so far:

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 an error Error 2003 Cannot connect to mysql server on '192.168.xxx.xxx'.

The IP being feed to SQLYog, I got it from ifconfig. Supplied the inet addr.

inet addr:192.168.226.xxx  Bcast:192.168.226.yyy

Is the address being used is incorrect or are these grant issues? Please advice.

like image 757
Mono Jamoon Avatar asked Jun 06 '13 05:06

Mono Jamoon


People also ask

How do I connect to a local MySQL server?

Step 3: Connect to a Local MySQL ServerEnter mysql.exe -uroot -p , and MySQL will launch using the root user. MySQL will prompt you for your password. Enter the password from the user account you specified with the –u tag, and you'll connect to the MySQL server.

How do I connect to a MySQL IP address?

Select Connections from the SQL navigation menu. In the Authorized networks section, click Add network and enter the IP address of the machine where the client is installed. Note: The IP address of the instance and the mysql client IP address you authorize must be the same IP version: either IPv4 or IPv6. Click Done.


Video Answer


1 Answers

You problem is that (probably) your mysql is bind to 127.0.0.1 instead of 0.0.0.0.

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

bind-address = 0.0.0.0

And then restart mysql of course.

like image 56
Arkadiusz 'flies' Rzadkowolski Avatar answered Oct 09 '22 06:10

Arkadiusz 'flies' Rzadkowolski