How does WordPress modify the table prefix of a Mysql database?

Source: Internet
Author: User
Tags wordpress database

How does WordPress modify the table prefix of a Mysql database?

We know that you can set a prefix for the WordPress database table. The default value is wp _. Many users use wp _ by default. For some reason (such as improving security) what should we do if we want to modify the prefix of WordPress data?

 Before getting started

Modifying data is a highly risky task and must be done well before you begin.Database Backup, OrSet the blog status to maintenance.

Modify database prefix 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, find your database, and run the following SQL statement to change the prefixes of all database tables 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_taxono'my 'TO 'wpjam _ term_taxonomy ';

RENAME table 'wp _ usermeta' TO 'wpjam _ usermeta ';

RENAME table 'wp _ users' TO 'wpjam _ users ';

  Modify data in the Options table

Use the following statement to change the value of option_name starting with wp _ in the options table to start with wpjam.

Select replace (option_name, 'wp _ ', 'wpjam _') FROM wpjam_options;

 Modify data in the UserMeta table

Use the following statement to change the value of meta_key starting with wp _ in the UserMeta table to start with wpjam.

Select replace (meta_key, 'wp _ ', 'wpjam _') FROM wpjam_usermeta;

Get it done, close the job!

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.