Connect to remote database using Localhost install

I will be designing and developing a website for a client but want to allow the client to add content while I am working on the design and development of the site so that it is pretty mich done by the time I am finished.

Currently, I use XAMPP on port 81 so my project URL looks something like

Read More
http://localhost:81/projectname

My wp-config file has all the settings I need to the remote DB and yet, when I run the

http://localhost:81/projectname 

URL it constantly redirects me to

http://localhost/projectname.

I’ve removed all htaccess files thinking the problem was there but that didn’t work. My ISP suggested opening port 3306 which I have done but that’s not done the trick either.

I don’t know if it has to do with port 81 on Xampp perhaps?

EDIT:
General settings link through to the online version of the site so

Site Address = http://example.com

WP Address = http://example.com

Many thanks

Related posts

2 comments

  1. I think s_ha_dum is in the right track, but I think he got it backwards.

    You want to:

    1. develop/design locally
    2. connect to the REMOTE database and work with his content?

    You need a remote (staging) installation of WordPress, where the client can create/enter his content.

    You need your local WordPress site (localhost) to point to the remote database, to grab the content he is using.

    So, you would have your http://example.com/wordpress set up for the client to edit – just even with a vanilla WP install. This site would be connected to it’s own database.

    Your localhost site would have the REMOTE site’s database credentials, with the DB_HOST set to http://example.com, or whatever the mySQL path is if it’s accessed another way through your hosting provider.

    On your local site, keep the WP_SITEURL and WP_HOME set to localhost. Otherwise, you’ll get redirection loops.

  2. Is there no way to pull the content to a localhost site just to get
    the content onto the site so that I can work on the development of the
    site while the client adds the content to the live DB?

    If the remote server supports it, you can connect to the remote database. Just set your connection constants correctly:

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define( 'DB_NAME', 'database_name_here' );
    
    /** MySQL database username */
    define( 'DB_USER', 'username_here' );
    
    /** MySQL database password */
    define( 'DB_PASSWORD', 'password_here' );
    
    /** MySQL hostname */
    define( 'DB_HOST', 'localhost' );
    

    You will almost certainly also have to set these on the local install:

    define( 'WP_SITEURL', 'http://example.com/wordpress' );
    define( 'WP_SITEURL', 'http://example.com/wordpress' );
    

    I can almost guarantee that you are still going to have issues, not to mention that changes you make are to the live server.

    There are other potential solutions, like database mirroring, but that would be off-topic here and I’ve never done it.

    My advice is to just copy the live database to your local server at the project start and do not try to sync the databases or otherwise connect the development site with the live one. You are asking for trouble. WordPress does not have a sharp content/config separation in the database.

Comments are closed.