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:
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!