Access permission error and countermeasures when changing DB prefix in WordPress

After changing the database (DB) prefix in WordPress, you may encounter a problem that you cannot enter the administration page with the message “You do not have permission to access this page.

This is because when the prefix is changed, it cannot be handled by simply changing the DB table name. Specifically, since the prefix is also used in tables such as user_meta, you need to change the prefix in these tables at the same time.

To do so, use the search-replace command of WP-CLI, the CLI tool of WordPress. You can replace prefixes in the whole DB by executing the following command.

wp search-replace 'sample_' 'wp_'

The above command will replace the string ‘sample_’ with ‘wp_’ in the DB. In this way, the prefix change is fully reflected, thus eliminating the access permission error.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top