views:

80

answers:

1

I am using ubuntu in VMWare. I installed mysql and have it running. I can login with the user root and a password. I have the IP of the VM box. In my code i wrote

using MySql.Data; return new MySql.Data.MySqlClient.MySqlConnection("username=root;data source=192.168.100.129,password=xyz");

instead of data source i also tried server. I get the exception message Unable to connect to any of the specified MySQL hosts.

i ran netstat -an | grep -i mysql and saw unix 2 [ ACC ] STREAM LISTENING 23404 /var/run/mysqld/mysqld.sock

so i added port=23404; and tried both data source and server. No luck. I can indeed ping that address on the virtual machine (i got the address using ifconfig). So Whats my problem and how do i connect? This is the first time i am using this. I always used sqlite in the past.

+1  A: 

Sounds like a MySQL problem rather than a .NET problem. By default MySQL only listens for connections from localhost (for security reasons). You need to explicitly tell it not to do so. See this: http://www.howtogeek.com/howto/mysql/switch-mysql-to-listen-on-tcp/ .

ionut bizau
I realized this a minute after i posted. I have done it and i still get the error after i restarted the server.
acidzombie24
Did you try connecting from a MySQL client instead of from .NET?
ionut bizau