Generating a new administrator user in WordPress through SQL

If you need access to a website, built on WordPress, but you have SSH access only, you could still cope with the situation with a few line in the command line.

Here are the steps you need to follow:

  1. Find the database credentials. They are usually in wp-config.php file under the web-root directory of your WordPress based website.
  2. Connect to the database, using the credentials from the configuration file, using the following command
  3.  Switch to your database:
  4. Create your user:
  5. Check the id of the newly created user. Try to guess the right SELECT, and if you can’t, go standing face to the wall and repeat a hundred times “I should not mess with the database if I don’t understand basic SQL.”. Seriously.
  6. Make your user an administator with this:

    Now you should be able to login with your username and password.
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *