Title: Seperate files one DB
Last modified: June 13, 2018

---

# Seperate files one DB

 *  [duocia](https://wordpress.org/support/users/duocia/)
 * (@duocia)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/)
 * Hello, so I have one wordpress in server, and one locally. But I want to use 
   remote database in my local wordpress. But the problem is that it always redirects
   me to the remote server as the site_url in database is from online version of
   wordpress. Is it possible somehow to define server url in php?
    I tried these
   but do not work. Also I have Multisite enabled.
 *  define(‘RELOCATE’,true);
    define(‘WP_HOME’,’[http://example.com&#8217](http://example.com&#8217););
   define(‘WP_SITEURL’,’[http://example.com&#8217](http://example.com&#8217););

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/seperate-files-one-db/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/seperate-files-one-db/page/2/?output_format=md)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395559)
 * The DB_HOST line of your wp-config.php file points to the database server.
 *  Thread Starter [duocia](https://wordpress.org/support/users/duocia/)
 * (@duocia)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395582)
 * Yes, and it is pointing to remote database, but when I try opening website on
   my localhost I get redirected to that exact server. But how avoid redirecting
   but use same database is my question?
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395596)
 * You can dynamically set the URLs WP_HOME and WP_SITEURL
 * See the first response at [https://stackoverflow.com/questions/26014426/how-to-set-dynamic-home-and-siteurl-in-wordpress](https://stackoverflow.com/questions/26014426/how-to-set-dynamic-home-and-siteurl-in-wordpress)
 * At least, I think that’s what you’re asking about.
 *  Thread Starter [duocia](https://wordpress.org/support/users/duocia/)
 * (@duocia)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395607)
 * I have this in my wp-config:
 *  $base = ‘/’;
    define( ‘WP_ALLOW_MULTISITE’, true ); define( ‘WP_HOME’, ‘[http://localhost/mmo&#8217](http://localhost/mmo&#8217););
   define( ‘WP_SITEURL’, ‘[http://localhost/mmo&#8217](http://localhost/mmo&#8217););
   define( ‘MULTISITE’, true ); define( ‘SUBDOMAIN_INSTALL’, false ); define( ‘DOMAIN_CURRENT_SITE’,‘
   localhost’ ); define( ‘PATH_CURRENT_SITE’, ‘/mmo/’ ); define( ‘SITE_ID_CURRENT_SITE’,
   1 ); define( ‘ADMIN_COOKIE_PATH’, ‘/’ ); define( ‘COOKIE_DOMAIN’, ” ); define(‘
   COOKIEPATH’, ” ); define( ‘SITECOOKIEPATH’, ” ); define( ‘NOBLOGREDIRECT’, ‘[http://localhost/mmo&#8217](http://localhost/mmo&#8217););
 * but I get: **Error establishing a database connection**
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395616)
 * Does your database allow remote connections? Check it’s config and the host’s
   firewall.
 *  Thread Starter [duocia](https://wordpress.org/support/users/duocia/)
 * (@duocia)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395641)
 * Yes, remote connections are allowed this is simple picture of what I want to 
   achieve. [https://prnt.sc/juhp6t](https://prnt.sc/juhp6t)
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395649)
 * What is your DB_HOST line in each config? Also, does the DB_USER have permissions
   as DB_USER@localhost and DB_USER@yourotherservername?
    -  This reply was modified 7 years, 11 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  Thread Starter [duocia](https://wordpress.org/support/users/duocia/)
 * (@duocia)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395653)
 * define(‘DB_HOST’, ‘79.98.30.144’);
    -  This reply was modified 7 years, 11 months ago by [duocia](https://wordpress.org/support/users/duocia/).
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395662)
 * How is the DB_USER defined on the DB server? Does it have a wild card as host?
 *  Thread Starter [duocia](https://wordpress.org/support/users/duocia/)
 * (@duocia)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395684)
 * This is my connection lines, I know that connection works because, Because I 
   made connection from my local phpmyadmin to remote database.
 * define(‘DB_NAME’, ‘mmo’);
 * /** MySQL database username */
    define(‘DB_USER’, ‘mmo’);
 * /** MySQL database password */
    define(‘DB_PASSWORD’, ‘*****’);
 * /** MySQL hostname */
    define(‘DB_HOST’, ‘79.98.30.144’);
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395712)
 * so, on your own PC
 * `mysql -u mmo -p***** -h 79.98.30.144 mmo`
 * works? If not, what error do you get?
    -  This reply was modified 7 years, 11 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  Thread Starter [duocia](https://wordpress.org/support/users/duocia/)
 * (@duocia)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395747)
 * Just a bit modified line 🙂
    [https://prnt.sc/jui77h](https://prnt.sc/jui77h)
 * Without define( ‘MULTISITE’, true ) website works fine, but I cannot access other
   sites…
    -  This reply was modified 7 years, 11 months ago by [duocia](https://wordpress.org/support/users/duocia/).
    -  This reply was modified 7 years, 11 months ago by [duocia](https://wordpress.org/support/users/duocia/).
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395778)
 * Try a couple of things:
 * 1. `define( 'DB_HOST', '79.98.30.144:3306' );`
 * and because I’m not sure about that
 * 2. in /etc/hosts (or wherever your hosts file might be), add
    `79.98.30.144 mysql.
   remote.host`, then use `define( 'DB_HOST', 'mysql.remote.host' );`
 *  Thread Starter [duocia](https://wordpress.org/support/users/duocia/)
 * (@duocia)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395812)
 * I have Xampp, this should be in mysql config or apache?
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/#post-10395819)
 * I don’t use XAMPP. You’ll have to check its documentation.

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/seperate-files-one-db/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/seperate-files-one-db/page/2/?output_format=md)

The topic ‘Seperate files one DB’ is closed to new replies.

 * In: [Localhost Installs](https://wordpress.org/support/forum/localhost-installs/)
 * 18 replies
 * 3 participants
 * Last reply from: [Dion](https://wordpress.org/support/users/diondesigns/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/seperate-files-one-db/page/2/#post-10396463)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
