开发者

How do i connect to a remote mysql server in .NET?

开发者 https://www.devze.com 2022-12-13 19:15 出处:网络
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

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.D开发者_JS百科ata.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.


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/ .

0

精彩评论

暂无评论...
验证码 换一张
取 消