简体   繁体   中英

“Unable To Connect To Any Of The Specified MySQL Hosts”

Thanks in advance for your patience. As I began typing this, I noticed SO has added the feature in the subject line for browsing similar topics. After exhausting my resources, I am going to continue this post.

I have two machines on a local network.
Production Box - Ubuntu, Apache, Mono, Asp.net, C# (ALL up to date).
Development Box - Windows XP with Xamarin

My Production box hosts out of port 80 on my WAN ip, so I can visit my website from my mobile device (production test) or from my development box (browser production test, or remote development env test using Xamarin).

My connection string most certainly adheres to: server=$servername$;port=3306;database=$databasename$;uid=$username$;password=$password$;

I have used all four server value combinations ([SERVERNAME],localhost, 127.0.0.1, actual network IP for remote dev env test).

I have bind-address: 127.0.0.1 in my cnf.

I continue to get "Unable To Connect To Any Of The Specified MySQL Hosts" server 500 error every time I visit my site, either using a production test (visiting the site by typing in my WAN IP into a browser, Apache is on the same box as MySql) or remote connection (development client, Xamarin debugger).

netstat says I am listening on port 3306.

I tried removing port 3306 from the connection string.

I tried using different combinations of PASSWORD/PWD USER ID/UID/USER.

ALL FAILURE. Please help!

If you have bound 127.0.0.1 in your my.cnf file that means you can only connect to the database from the local database computer. 127.0.0.1 is the local loopback address, only allow localhost connections. If you're website isn't hosted on the same server this is why you can't connect.

If you want to connect to your database from another server bind the LAN IP of the database server in the my.cnf file.

You can then put the LAN IP address of the database server into the connection string and you should be able to connect

Your error is actually a network connection error, you aren't authenticating yet so trying different usernames and passwords isn't going to help. Once you've sorted out the network issues you will receive a different error if the authentication fails (for example user@host using password failed)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM