How to create an Administrator user via MySQL – WordPress

Have you ever needed to create a new user in WordPress through MySQL?

It's more common than you thing. A new client comes in and he already has a WordPress site. You want to create your account and you just don't want to bother him asking for his user and password.

Here's the three queries that will create a new user with Administrator role.

Username: demo
Password: demo

Customize it with your name or email to fit your needs 😉


INSERT INTO `wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('demo'), 'Your Name', 'test@example.com', 'http://www.example.com/', '2011-06-07 00:00:00', '', '0', 'Your Name');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');

About Rick

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*