I'm trying to connect to my mysql database from an external web server. I added the servers IP address as a trusted site so it can access it remotely. I realize this is an error with the external server and not the main server the database resides on because I tried it with another external server and it worked. Anyways here is the message I get when I try to make a database connection from the external server. The X's are private info. Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'XXXX' (4) in /home/XXXX/public_html/newserverdb.php on line 4 Could not connect: Can't connect to MySQL server on 'XXXXX' (4) Any help would be appreciated.
Where did you add this? To access MySQL database you must allow your MySQL user to access database remotely. Set the MySQL user access permissions remotely by adding a remote IP instead of localhost.
Most hosting provider blocks port# 3306 due to security reasons. so, even if you add server IP address as a trusted site, you won't be able to can access it remotely. Check with your hosting provider first.
I have 3 servers. One is a VPS and the other two are shared. I'm trying to access one of the shared host with the VPS, but it wont connect. The two shared host can connect with each other, but the VPS cannot connect to either. Now the two shared host can connect to the VPS no problem, but the problem is vice versa. The script runs from one of the shared host and the VPS needs to to connect to this script but I keep getting this error. I don't think it's a problem with the shared host because they can connect with each other, and they are from two different providers(Bluehost, Hostmonster). So it's probably the VPS.
You might have the connection information specified incorrectly. I remember running into these connectivity issues myself and I was using HostMonster. I forget the "trick" that I used to get it working. I can give you a sample of what my connection information looks like though: Host Address: hostXXX.hostmonster.com [where XXX is your host box number] UserName: mysoft_root [where mysoft is my HostMonster account name, root is my username] Password: ******* [whatever you set it to in cpanel] Port: 3306 Database Name: mysoft_mspmain [where mysoft is my HostMonster account name, mspmain is database name] I also had to whitelist the IP address of the server that is connecting, which can be done through the cPanel. P.S: HostMonster and BlueHost are run by the same parent company, so this information should also be helpful even if the database is hosted on BlueHost.
Thanks jimpossible2k "whitelist" was the key. I should have done this a while ago, but I entered their live chat and asked for help since I knew I would have to contact them to add the ip(other than what I did in cpanel). And it worked. They added it to the whitelist on their end and it worked. And I didn't know Hostmonster and Bluehost were owned by the same company, it's probably why their servers can connect to each other, but outside ones have to be added to the whitelist through support.
check the setting , ip dbname , username password. then google the erro code to view which is the most possible reason to cause the connection failure.