45Squared

Add a User to WordPress with MySQL

I’ve taken over hosting for many WordPress websites. Almost always they were designed by someone else and the customer doesn’t have access. So, below I have compiled a few MySQL queries for you to run against a database to create an administrator on a new migrated website.

Disclaimer

While we write guides that are easy to follow, we can’t ensure that your website will be 100% protected or safe from any negative actions done by outside actors. If you want to be sure that your website is secure feel free to reach out and we will do a free consultation on disaster recovery

Connecting to your MySQL Database

This guide assumes that you have some experience working with MySQL. If you don’t, please contact me using the form below or any social media account! I would love to help you before you obliterate your database.

There are a few ways to connect to MySQL:

  • PHPMYADMIN
  • MySQL Workbench
  • Command Line

Personally, I do all my MySQL queries on the command line as my databases are hosted in Amazon RDS. I’m not going to get into how to execute a query on each of these platforms but the queries below have been tested on each one.

MySQL Queries

First query will create your user. You will need to modify a few sections in this query including the table prefix if you changed it when you installed WordPress. Other things to change will be the username you want to use, your password, your name and email.

insert into `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`) VALUES ('YOUR_USERNAME', MD5('YOUR_PASSWORD'), 'YOUR_FULL_NAME', 'YOUR_EMAIL', '0');

This next query will give your user administrative capabilities. Be sure to modify the tables as needed.

insert into `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

And finally, set the user level to 10. While this was deprecated many years ago, I still set it to 10.

insert into `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');

Need help with your WordPress installation? Contact us today and let’s see what we can do to help!

    Share This Guide, Choose Your Platform!

    Connect with 45Squared

    Exit mobile version