Skip to content
Logo
  • Home
  • About us
  • Our Services
  • Our Work
  • Blog Categories
    • Beginners Guide
    • WordPress
      • WordPress Themes
      • WordPress Security
      • WordPress Tutorials
      • WordPress Hosting
      • WordPress News
    • SEO Tips
    • Product Reviews
Menu
  • Home
  • About us
  • Our Services
  • Our Work
  • Blog Categories
    • Beginners Guide
    • WordPress
      • WordPress Themes
      • WordPress Security
      • WordPress Tutorials
      • WordPress Hosting
      • WordPress News
    • SEO Tips
    • Product Reviews
Contact us

How to Create WordPress Admin User via MySQL

  • April 19, 2018
  • Saddam Kassim
create wordpress admin user

While developing a blog or website on WordPress, it happens sometimes that I have been locked out of my WordPress Dashboard.

This could happen due to any code error, any accidental deletion of admin account or because of website malicious attack.

In such case, how can you create another new admin account if you are unable to login to your existing WordPress admin account?

Well, I have found an easy to handle method for such situation where you can create a new WordPress admin account and regain access to all administration interface.

You just need to add few lines of code in your MySQL database.

Relax! Do not worry, it’s too easy.

Below is a step by step guide to creating WordPress admin user via MySQL through cPanel. I have also written a complete guide on How to create a user in WordPress Dashboard.

Create WordPress Admin User

Note: It is important for you to understand the prefix of your WordPress Database Tables. Check in your MySQL database where your DB tables would be having such prefixes like “wp_” or “wptable_” etc.

The code that I am providing below should be adjusted as per your DB tables prefixes. For example, if your database tables are using “wptables_” prefix instead of “wp_”, then the code “INSERT INTO `wp_users`” would be “INSERT INTO `wptables_users`”.

Step 1: Login into your hosting cPanel and click on phpMyAdmin.

phpmyadmin

Step 2: Here you will see a list of your available databases. Click on the “+” symbol to expand your database tables and then hit your “wp_users” table. In my case, it is “wpzm_users“.

create admin account

Step 3: Now, click on the top “SQL” tab and paste this code inside the query box.

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES (‘newadmin’, MD5(‘pass123’), ‘firstname lastname’, ’email@example.com’, ‘0’);

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″;}’);

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), ‘wp_user_level’, ’10’);

Step 4: Replace the following in order to create the admin account in WordPress successfully:

  1. Replace “newadmin” with your desired new username. Example “newadmin“.
  2. Replace “pass123” with your desired new secure password.
  3. Replace “wp_users” with your exact users table name. For example “wpzm_users” in my case. (For reference check snapshot in step 2)
  4. Hit the “Go” button at the bottom right corner. That’s all.

admin account created successfully

You have successfully created a new admin user for your WordPress website via cPanel. Your screen will refreshed for a second and a message will appear “1 row affected” after each three SQL statements.

This means that the insertion of your new SQL query ran successfully and now you can visit your WordPress login URL and try to login with your new admin account details.

Hope this was easy for you to create admin account in WordPress via cPanel.

I think these articles are useful too:

Top 8 useful plugins for WordPress blog
Monetize your WordPress blog with Google Adsense
Create a money making blog in few steps
Create a Contact form with WPForms plugin
14 best blogging platforms (@creativebloq.com)

Share:

More Posts

Free Local Server for WordPress Website

No doubt, WordPress is a very powerful content management system which can be used to build amazing websites. Though WordPress is an open-source tool but

whatsapp chat logo

WhatsApp Chat on WordPress Website 2024

In this article, you will learn How to add Whatsapp Chat on WordPress Website. In earlier days, you were having only the basic contact forms

backup wordpress site

How to Backup WordPress site for Free with UpdraftPlus

Last Update: 8 March 2019. Backups are very important in terms of your WordPress website security against threats. Regular backups are one of the most

best wordpress contact form

5 Best Contact Form Plugins for WordPress in 2024

Hey! Are you looking to add a contact form on your WordPress website? Not yet decided which one is the best contact form plugin to

Send Us A Message

PrevPreviousMonetize Your Blog to Earn Money: Google Adsense
Next6 Steps to Speed Up WordPress WebsiteNext
Logo

We are a Digital Marketing Agency offering various services including web development, search engine optimization, graphics designing, content writing, and paid promotion.

Youtube Facebook
Quick Links
  • About
  • Disclaimer
  • Privacy Policy
  • Affiliate Disclosure
  • Terms of Service
  • Contact
  • About
  • Disclaimer
  • Privacy Policy
  • Affiliate Disclosure
  • Terms of Service
  • Contact
Get In Touch
  • Email: support@websoftglobal.com
  • Phone: +91-9555248544
  • Hours: Mon-Fri 11:00AM - 6:00PM

© 2024 – All Rights Reserved | Websoft Global IT Services