Create a WordPress admin user with MySQL

Sometimes we have been looked out of WordPress installation but have access to the database.So here is a way to create a WordPress user with administrator-level access. Before proceeding further set the variables to your own information. Next, if your WordPress installation is using a non-standard wp_ table prefix, you must find/replace ‘wp_’ with your current table prefix.

SET @id = 2;

SET @user = 'username';

SET @pass = 'password';

SET @email = 'email@ddress';

SET @name = 'Your Name';


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 (@id, @user, MD5(@pass), @name, @email, '', '2013-06-20 00:00:00', '', '0', @name);

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

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

INSERT INTO  wp_usermeta (umeta_id, user_id, meta_key, meta_value

Done.