Disable All WordPress Plugins

It can happen that a faulty plugin breaks your WordPress site. Even worse, depending on how serious the error is, you can end up being unable to access the admin area where you would have been able to deactivate the WordPress plugin causing the error.

In that case, the best thing to do is to deactivate all plugins using the following SQL query:

UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';

Most likely, this will solve the error and allow you to log back into your WP dashboard. Then you can re-activate the plugins one by one and identify which one was causing problems.

How to Reset a Forgotten WordPress Admin Password

To strengthen the security of your WordPress website, creating and using a strong complex password for your admin account is very critical. But there is one thing I hate about strong and complex passwords, they are easily forgettable. That’s the only risk involved in using complex passwords on your website. So in this article, I will show you a couple of ways to recover or reset your forgotten WordPress admin password. If you run a WordPress website then it’s very essential to keep these tips handy.

In WordPress, there is more than one way to reset the WordPress admin passwords. In normal circumstances, you can do it through the forgot password link on the WordPress login interface. But sometimes, you don’t have that option and have to take different steps to reset your password, especially if you disable forgot password feature.

Here I am listing 2 different ways to reset the WordPress admin password. Any one of them will work, and you only need one to succeed. Which method you will use depends on what type of access you still have to your website.

With FTP

If you have FTP access to your website then you can paste the following code snippet in your theme’s functions.php file. This will change the password of user id 1 with “New Password”. Make sure you change the “New Password” string with your desired password and user ID before you use this code.

// reset forgotten wordpress admin password with functions.php
wp_set_password( 'New Password', 1 );

Please note: This code should be deleted after the first page load, otherwise the password will be reset on every subsequent load, sending the user back to the login screen each time.

With MySQL

If you have phpMyAdmin or MySQL access then you can simply run this MySQL query in your database to reset the password of a user. Before executing this query, change the “New Password” string to your new password and edit the user-login name “admin” and table-prefix value “wp_” if necessary.

// reset forgotten wordpress admin password with mysql
UPDATE wp_users SET user_pass = MD5('New Password') WHERE user_login = "admin";

Create WordPress Database using MySql Client

You can create MySQL users and databases quickly and easily by running mysql from the shell. The syntax is shown below and the dollar sign is the command prompt:

$ mysql -u adminusername -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5340 to server version: 3.23.54

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"hostname"
-> IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec) 

mysql> EXIT
Bye
$ 

The example shows:

  • that root is also the adminusername. It is a safer practice to choose a so-called “mortal” account as your mysql admin, so that you are not entering the command “mysql” as the root user on your system. (Any time you can avoid doing work as root you decrease your chance of being exploited.) The name you use depends on the name you assigned as the database administrator using mysqladmin.
  • wordpress or blog are good values for databasename.
  • wordpress is a good value for wordpressusername but you should realize that, since it is used here, the entire world will know it, too.
  • hostname will usually be localhost. If you don’t know what this value should be, check with your system administrator if you are not the admin for your WordPress host. If you are the system admin, consider using a non-root account to administer your database.
  • password should be a difficult-to-guess password, ideally containing a combination of upper- and lower-case letters, numbers, and symbols. One good way of avoiding the use of a word found in a dictionary is to use the first letter of each word in a phrase that you find easy to remember.

If you need to write these values somewhere, avoid writing them in the system that contains the things protected by them. You need to remember the value used for databasename, wordpressusername, hostname, and password. Of course, since they are already in (or will be in shortly) your wp-config.php file, there is no need to put them somewhere else, too.

See Creating Database for WordPress.