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

Multiple WordPress sites use the same database

爱喝马黛茶的安东尼
Release: 2019-07-18 16:29:30
Original
4165 people have browsed it

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_';
Copy after login

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_';
Copy after login

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';
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template