Change WordPress User role from Database using PHPMyAdmin

Change WordPress User role from Database using PHPMyAdmin, You can update any WordPress user information like changing user role and updating an email from admin panel. But if you want to update or change an user role from MySQL database using PHPMyAdmin or SQL, you can do that. Before making any changes to user role, you need to get user id which you want to update user role.

For updating user role you need to have user id, then you need to access wp_usermeta table.

In wp_usermeta table, you can find wp_capabilities under meta_key. And find wp_capabilities with same user id for which you want to update.

From this screenshot, you can understand, what you need to select using query or what you need to search using PHPMyAdmin.

Change WordPress User role from Database using PHPMyAdmin

wp_usermeta table and data for wp_capabilities

In the field of meta_value, the value should be a:1:{s:13:”administrator”;b:1;}

Below is SQL for updating an user role as administrator. Here I’m assuming user id as 2.

[sql] UPDATE wp_usermeta SET meta_value=’a:1:{s:13:"administrator";b:1;}’ WHERE user_id=2 AND meta_key=’wp_capabilities’

You can use above sql to update user role in any WordPress website but just change the user id with the actual user id you can update the user role for.

Vivek Vengala

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.