Host my wordpress site locally using the server database

I have set up my wordpress site on my local machine and I would like it to talk to the live mysql database on the server. I accessed the wp-config.php file on my machine and changed the hostname to use the ip address instead of localhost, but it will not work.

What do I need to do?

Related posts

Leave a Reply

2 comments

  1. It could be that your remote database is configured to accept connections only from localhost for security reasons. Most web providers set it up that way. In that case, you have no chance of making this work.

    Anyway, even if you would get it to work, you will encounter two problems: It will be awfully slow, and the HTML served by the remote database will contain references to server URLs (as opposed to local ones).

    If you need more detailed information, you will need to post any error messages you get from mySQL.

  2. Alternatively, you can try running the mysql command-line utility to connect.

    mysql -u username -h server -p wordpress_database
    

    Make sure that works first before attempting to get WordPress to connect.

    My guess is you won’t be able to connect due to firewall issues. MySql uses port 3306 by default, so if the server’s firewall doesn’t allow connections through that port, you’ll either have to change the port mysql is using (probably a bad idea if other apps expect to see MySql on that port) or get that port opened on the server (make sure you only open it for local IPs, so someone else can’t get to your MySql instance!)