google-templateswordpress

Reset the WordPress administrator permissions

NOTE: A multi-tier environment typically consists of multiple servers. The steps below should be performed on the runtime server (the server instance running the application), which includes a mysql client. For more information on connecting via SSH, refer to the FAQ.

First, obtain the user ID for the WordPress administrator account from the command line:

$ mysql -u root -h DATABASEHOST -p bitnami_wordpress -e "SELECT * FROM wp_users;"

Replace the DATABASEHOST placeholder with the host where the database is running.

Then, use the command below to reset the administrator permissions from the command line:

$ mysql -u root -h DATABASEHOST -p bitnami_wordpress -e "UPDATE wp_usermeta SET meta_value='a:1:{s:13:"administrator";b:1;}' WHERE user_id='ADMIN-ID' LIMIT 1;"

Remember to replace the DATABASEHOST placeholder with the host where the database is running and the ADMIN-ID placeholder with the user ID obtained from the first command.

To obtain the hostname where the database is running, you can execute the following command

$ sudo cat /opt/bitnami/wordpress/wp-config.php | grep 'DB_HOST'

You should see an output similar to this:

define('DB_HOST', 'provisioner-peer:3306');

In this case, the DATABASEHOST placeholder should be replace by “provisioner-peer”.

Last modification May 22, 2023