Reputation: 65
I was tried to clone my Wordpress to subdomain and changed this line from example.com to test.example.com:
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'test.example.com'); // <- this line
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
But after that my site on subdomain call: Error establishing a database connection.
My wp-config.php file declare correct the database information (tested with mysql_connect() function).
How to fix it??
Upvotes: 1
Views: 1395
Reputation: 1
Also check in wp-config.php
if multisite if you are setting subdomain to true
define('SUBDOMAIN_INSTALL', true);
Upvotes: 0
Reputation: 545
Are you trying to use the same database for two Wordpress installations? The main Wordpress and the Wordpress on subdomain?
Create a new database and note the name, username of the user associated with the database with all privileges and the password of the user. Take a backup of your main database and import the backup in your new database.
Then in your new database, find wp_options
and change site_url
and home_url
to your subdomain.
Then as @F5 Buddy said, change the following in your config.php
define('DB_NAME', 'wordpress');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
Try and access the admin panel by going to subdomain/wp-admin
. See if that works. Login using your main Wordpress username and password. Once logged into the admin panel, don't forget to refresh the Permalinks by going to Settings -> Permalinks
and clicking on Save; otherwise only your homepage will be linked correctly.
Hope this helps.
Upvotes: 2
Reputation: 494
define('DB_NAME', 'wordpress');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8mb4');
define('DB_COLLATE', '');
After that you have to change site_url and home_url in database table "wp_options" then run again.
Upvotes: 1