Changing a wordpress user to an admin

前端 未结 3 1859
刺人心
刺人心 2021-02-09 20:09

I am trying to set up a local copy of a production Wordpress blog. On production, I am a user but not an admin, so I am trying to change myself to an admin locally. I was follow

3条回答
  •  野性不改
    2021-02-09 20:42

    If you have already have your username and password then you just need to update capability and role into database.

    Go to wp_user table and locate your ID from there i.e. in my case its 2. And then go to wp_usermeta and look for meta_key = wp_capabilities and user_id - 2. Edit that row and change meta_value to

    a:1:{s:13:"administrator";s:1:"1";}.
    

    Again go for meta_key = wp_user_level and user_id = 2. Edit that row and change meta_value to 10. Don't change other rows where user_id is not your own.

    See my wp_users table. Look for the ID

    See my wp_usermeta table. Look for capabilities and roles

    Two queries will be fired something like these:

    UPDATE `wp_usermeta` SET `meta_value` = '10' WHERE `wp_usermeta`.`umeta_id` =27;
    
    UPDATE `wp_usermeta` SET `meta_value` = 'a:1:{s:13:"administrator";s:1:"1";}' WHERE `wp_usermeta`.`umeta_id` =26;
    

提交回复
热议问题