Magento – How to configure Magento to connect to a remote database

databasemagento-1.9

I am trying to set up a local repo of Magento on Windows that will connect to a remote database running on CentOS. The CentOS server has the full LAMP stack and Magento installed and running. The local Windows machine has Apache, PHP and Magento installed. All I was to do is change my local.xml file on the Windows machine to point to the remote database running on the CentOS server. I changed the local.xml file to point to the server IP with the magento db user/pass, but I keep getting the following error:

SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

I can SSH to the CentOS database, but I can't figure out how to make Magento connect to it. Any ideas?

Best Answer

This is probably not a Magento problem but something you didn't configure in your remote server. Most of the time MySql servers only accept connections from localhost or 127.0.0.1 and this is not the case.

Here you can find a guide to allow remote connections to your server, but please keep in mind this will expose your DB to the entire internet if not configured correctly.

Related Topic