I am unable to log in to my WordPress website. The website is working fine, and user credentials are correct.
Later I found that somehow the users
table got corrupted and now it got deleted.
Can you explain how I can create users
tables with an admin user login credentials so that I can log in back to my WordPress?
I have access to phpMyAdmin.
3
Answers
You can make a small PHP file, let’s call it
make_user.php
, containing the following code:Change your ADMIN_USER (account name) and ADMIN_MAIL to whatever you want.
Upload this to the root folder of your WP installation and call it by http://your.host/make_user.php .
You can either decide to uncomment the line echoing the password and use this, or just reset it via the regular Forgot password function (I’d do the latter).
Delete the file after you’re done.
Assuming your table name is
wp_users
adjust for your prefix.From:
wp-adminincludesschema.php Line 191
You can also add the Primary Keys and
AUTO_INCREMENT
via the phpMyAdmin Interface like so:Then follow these instructions:
How to Create a new Admin User for A WordPress Site via MySQL (PHPMyAdmin)?
Step 1: Create user_reg.php file in wp root folder and file containing the following code
Step 2: Run the file on browser like
http://example.com/user_reg.php
Step 3: If user-created successfully then try to login with given username and password