settingsAccountsettings
By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy
Menusettings

Q: How to Insert New Admin Account to my WordPress MySQL DB?

+3 votes

Hi, how can I create admin from my WordPress site by using MySQL?

Maybe with some queries?

I want to bypass writing a function in my functions.php file like here: https://forum.tutorials7.com/2348/how-add-user-administrator-to-cpanel-ftp-for-wordpress-site

Just want to use simple SQL query.

Thanks

asked in Web Development category by user ak47seo

1 Answer

+2 votes

My WordPress database is called childhood so you MUST change the name of yours + the other information (just replace it).

My new admin username is opa and the password is also opa (it will be hashed using MD5 hashing method).

Also, I’m giving the user id the value of 2. Make sure this isn’t already used in your database.

Here is the code (SQL query):

INSERT INTO `childhood`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('2', 'opa', MD5('opa'), 'Opa', 'your@email.com', 'http://www.yoursite.com/', '2018-06-07 00:00:00', '', '0', 'Alex');

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

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

Here is a screenshot from my PHPMyAdmin with the new admin user:

sql query new administrator in wordpress cms

Also - this video is very useful for understanding WordPress Database with phpMyAdmin + how to work with some of the SQL queries:

https://www.youtube.com/watch?v=2TE7dLY_VjQ

answered by user andrew
edited by user golearnweb
...