Maybe your WordPress site has been hacked or otherwise compromised and now you want to change all passwords of your WordPress installation. On one side you have to change all the passwords of your WordPress users. And you can change them – pretty easy – in the backend. Out there are – perceived – trillions of posts explaining how to do this. But if you are looking apart from that for a way to change the password of the WordPress database itself – in mysql or mariadb, not in tools like phpmyadmin – help is not within reach. But it is nevertheless easy. And you only have to change the password in the file wp-config.php and in your SQL server.
First step first: Change password in wp-config.php
First, open wp-config.php and look for the entry
define( ‚DB_PASSWORD‘, ‚actual_password‚ );
Alter the actual_password to your new password. Until now a good password was something like this: KU4Ó¶x@¢4M½.èF-+Ïbüç§ý]Ôñô>ékßvwPX)q¸>^E®öntæö/LuoÁÜ4-Us8d[f. It has 60 characters including extended ASCII characters – but now, that it is published, you should avoid it. But if you look carefully, you may consider, that it lacks a \ (backslash) and a ‚ (single quotation mark).
Hint: Never use a backslash or a single quotation mark in your WordPress database password, because the first one is interpreted as an ESC character and the second one is reserved in SQL. You neither need such a long password. 24 or 32 characters are strong enough.
In wp-config.php look also for the line
define( ‚DB_USER‘, ‚db_user‚ );
The name of the db_user is the user of your WordPress database, for which you want to change the password. So let´s go on to …
Step 2: Change the password in your SQL server
Log into your SQL server and type the following:
SET PASSWORD FOR ‚db_user‚@’localhost‘ = PASSWORD(‚new_password‚);
db_user is the user of your WordPress database, and new_password should be your new password. That´s it. Exit your SQL server and reload the WordPress site in your browser. It is that easy. Have fun.