Home  >  Article  >  CMS Tutorial  >  Multiple WordPress sites use the same database

Multiple WordPress sites use the same database

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-07-18 16:29:304099browse

Multiple WordPress sites use the same database

Using the same database for multiple WordPress sites can be achieved by modifying the table prefix (Table Prefix). There are two main situations:

WordPress has not been installed yet

Before initially configuring WordPress, change the $table_prefix value in wp-config.php (default is wp_) to the required table prefix (assumed to be blog_ in this article), and then install it all the way. Can.

Before modification:

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

After modification:

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'blog_';

Related recommendations: "WordPress Tutorial"

Installed WordPress

If WordPress has been installed, perform the following steps:

1. Modify the $table_prefix value wp_ in wp-config.php to the required table Prefix (blog_).

2. Modify the corresponding table prefixes in the MySQL database to the new table prefix, as shown below:

Multiple WordPress sites use the same database

3. Perform the following database update (please Modify the table prefix accordingly):

UPDATE blog_usermeta SET meta_key ='blog_capabilities' WHERE meta_key ='wp_capabilities';
UPDATE blog_usermeta SET meta_key ='blog_user_level' WHERE meta_key ='wp_user_level';
UPDATE blog_options SET option_name='blog_user_roles' WHERE option_name='wp_user_roles';

The above is the detailed content of Multiple WordPress sites use the same database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn