WordPress How to modify the MySQL database table prefix

Source: Internet
Author: User
Tags config php file table name wordpress database

We know that WordPress database table, you can set the prefix, the default is WP_, many students also default on the Wp_, if some reason (such as increased security) to modify the prefix of the WordPress data, what should we do?

 Before you start

Modifying the data is a high-risk job, the beginning must be a good database backup , you can also set the blog to maintain state .

Modifying database prefixes in wp-config.php

Open your wp-config.php file and change the database prefix wp_ to the prefix you want, such as WPJAM_.

$table _prefix = ' WPJAM_ ';

Modify data table name

Open Phpmysql, locate your database, and execute the following SQL, changing all database table prefixes from wp_ to WPJAM_.

RENAME table ' Wp_commentmeta ' to ' Wpjam_commentmeta ';

RENAME table ' wp_comments ' to ' wpjam_comments ';

RENAME table ' wp_links ' to ' wpjam_links ';

RENAME table ' wp_options ' to ' wpjam_options ';

RENAME table ' Wp_postmeta ' to ' Wpjam_postmeta ';

RENAME table ' wp_posts ' to ' wpjam_posts ';

RENAME table ' wp_terms ' to ' wpjam_terms ';

RENAME table ' wp_term_relationships ' to ' wpjam_term_relationships ';

RENAME table ' wp_term_taxonomy ' to ' wpjam_term_taxonomy ';

RENAME table ' Wp_usermeta ' to ' Wpjam_usermeta ';

RENAME table ' wp_users ' to ' wpjam_users ';

  Modify the data in the Options table

Use the following statement to change the option_name in the options table to the beginning of the WP_ with the value beginning with the WPJAM_.

SELECT REPLACE (option_name, ' wp_ ', ' wpjam_ ') from Wpjam_options;

 Modify the data in the Usermeta table

Use the following statement to change the Meta_key in the Usermeta table to the beginning of the WPJAM_ with the value of WP_.

SELECT REPLACE (Meta_key, ' wp_ ', ' wpjam_ ') from Wpjam_usermeta;

It's done!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.