Shahnawaz Khan
Shahnawaz Khan

Reputation: 13

Can I use 2 WordPress databases inside one single MySQL database

One of my clients wants that he has only one SQL database in that he wants to run 2 different SQL WordPress databases.

Is there any solution? thanks in advance..

Upvotes: 1

Views: 110

Answers (1)

cgrim
cgrim

Reputation: 5031

Yes, you can have one database with two (and more) WordPress instances (sites, blogs) where each instance must use different table prefix.

See here: https://codex.wordpress.org/Installing_WordPress and look for this sentence:

If you have only one database and it is already in use, you can install WordPress in it - just make sure to have a distinctive prefix for your tables to avoid over-writing any existing database tables.

Here you can find more info how to do it: https://codex.wordpress.org/Installing_Multiple_Blogs#Single_Database

In shortcut there is a wp-config.php file which will vary for each installation on this line:

$table_prefix = 'wp_';

Where wp_ is a default value but you should use different value here for each WordPress instance. For example for the first instance there will be:

$table_prefix = 'first_'; 

... and for the second instance:

$table_prefix = 'second_'; 

Then you will have in one MySQL database two sets of tables one prefixed by first_ and the second by second_.

Upvotes: 1

Related Questions