How to reset a forgotten WordPress admin password using mysql

You may have forgotten the admin username, and may also not have received any email from the site. In such a case, to reset your admin password, first login to your server, open a terminal, and login to mysql:

mysql -u root -p

Open your database
If you dont know the name of your table, locate it from the wordpress wp-config.php file:

grep 'DB_NAME' /home/drjoel/public_html/wp-config.php
define('DB_NAME', 'mydb_name');

Now in mysql, show a list of tables:

MariaDB [(none)]> use mydb_name;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mydb_name]> show tables;
+-------------------------------------------------+
| Tables_in_mydb_name                             |
+-------------------------------------------------+
| wp_ak_params                                    |
| wp_ak_profiles                                  |
| wp_ak_stats                                     |
| wp_ak_storage                                   |
| wp_ak_users                                     |
| wp_akeeba_common                                |
....
| wp_usermeta                                     |
| wp_users                                        |
| wp_wc_download_log                              |
....
| wp_yith_wcwl                                    |
| wp_yith_wcwl_lists                              |
+-------------------------------------------------+
53 rows in set (0.00 sec)

The table you’re interested in, is wp_users:
Now issue the command:

SELECT ID, user_login, user_pass FROM wp_users;

Note the ID corresponding to your admin username. Usually this is 1.
Now change to new password

UPDATE wp_users SET user_pass = MD5('New_pass') WHERE ID = 1;