Lab Hack: Updating WordPress “wp-admin” login from MySQL(MariaDB)
Connect into mysql from terminal
$ sudo mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 25680
Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| blk_wpdb |
+--------------------+
Then select from the wp_users field
MariaDB [(none)]> use blk_wpdb;
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 [blk_wpdb]> show tables;
+-------------------------------------------------+
| Tables_in_blk_wpdb |
+-------------------------------------------------+
| wp_commentmeta |
| wp_comments |
| wp_et_bloom_stats |
[ shortened for security purposes ]
| wp_usermeta |
| wp_users |
+-------------------------------------------------+
48 rows in set (0.001 sec)
MariaDB [blk_wpdb]> SELECT ID, user_login, user_pass FROM wp_users;
+----+----------------+------------------------------------+
| ID | user_login | user_pass |
+----+----------------+------------------------------------+
| 1 | wp-admin | $Z$BDoTAnbhsiwkIOHNKJhinlZ1MTy/nz0 |
+----+----------------+------------------------------------+
1 row in set (0.001 sec)
This is where the magic happens, just enter the new password as such
MariaDB [blk_wpdb]> SELECT ID, user_login, user_pass FROM wp_users;
+----+----------------+------------------------------------+
| ID | user_login | user_pass |
+----+----------------+------------------------------------+
| 1 | wp-admin | $Z$BDoTAnbhsiwkIOHNKJhinlZ1MTy/nz0 |
+----+----------------+------------------------------------+
1 row in set (0.001 sec)
MariaDB [blk_wpdb]> UPDATE wp_users SET user_pass = MD5('newpassword_here') WHERE ID = 1;
Query OK, 1 row affected (0.041 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [blk_wpdb]>