After subscribing a new VPS server from my hosting provider, I found that although I could access to Plesk control panel properly, I was unable to access MySQL with the same admin’s user and password as used in Plesk. As a result, I couldn’t do anything with the database from the command line or in any other way. So I decided to manually change the admin user’s password via the mysql shell. After making such change I could perfectly log in to MySQL, but nevertheless the Plesk control panel stopped working, throwing the following exception:
ERROR: PleskFatalException Unable to connect to database: saved admin password is incorrect. 0: common_func.php3:150 psaerror(string 'Unable to connect to database: saved admin password is incorrect.') 1: auth.php3:107 ERROR: PleskFatalException Unable to connect to database: saved admin password is incorrect. 0: common_func.php3:150 psaerror(string 'Unable to connect to database: saved admin password is incorrect.') 1: auth.php3:107
After an online search for information about this issue, I found many sites explaining different solutions. In summary, the solutions were as follows:
The password in /etc/psa/.psa.shadow file used to grant access to Plesk Panel database does not match the MySQL admin user’s password, so it must be replaced with the following commands:
~# export PSA_PASSWORD=<new_password> ~# /usr/local/psa/admin/bin/ch_admin_passwd <new_password>
However, this solution has not been such in my case as I always got the following error message, even though the mysqld daemon was running perfectly:
Unable to connect to database: 1045
Since I couldn’t change the Plesk password, I tried to adapt the MySQL password to that already existing in Plesk. Everybody usually knows that password. Otherwise we’ll have to run the following command, although it is quite possible that we meet the same error “Unable to connect to database: 1045” from above:
~# /usr/local/psa/bin/admin --show-password
To solve this issue, we’ll add the following to the [mysqld] section in /etc/mysql/my.cnf database configuration file and restart MySQL:
In this way we tell to MySQL not to do users and permissions checks, so the command “/usr/local/psa/bin/admin –show-password” now reports the password as set in Plesk, while we can also access MySQL as admin without knowing the password. This will allow us to set a password to our choice.
At this point most of the solutions to this problem I’ve checked, including the official solution from Plesk (https://kb.parallels.com/112492) go to change the admin user’s password:
~# /usr/bin/mysql -D mysql -e"UPDATE user SET password=PASSWORD('`cat /etc/psa/.psa.shadow`') WHERE User='admin';"
However, while it’s true that making this change results in Plesk Panel starts to work again with no more “Unable to connect to database: saved admin password is incorrect” exception messages, when we remove the skip-grant-tables parameter from /etc/mysql/my.cnf, MySQL refuses access again if we use the same password as set in Plesk.
Create an alternative user with all privileges from admin
The problem of both attempted solutions above were that we’re using the encrypted password from /etc/psa/.psa.shadow file to set MySQL password, not the password we actually want to use in clear text. Somewhere in the /usr/local/psa/admin/bin/ch_admin_passwd binary or elsewhere in Plesk there is an anomaly that does not give the password that we have assigned in clear text through the Plesk Panel to the admin user (later on MySQL internally takes care of storing it encrypted). Instead, the encrypted password from Plesk as it appears in the /etc/psa/.psa.shadow file is used, so we are always in a vicious circle where we can access to Plesk Panel and not to the database or viceversa.
We can resign and learn or write down the encrypted password somewhere, using it every time we access to MySQL, wich we’ll be able to do in a not very comfortable way, but with no problem.
But if we want to use our real password, that one we can easily remember and not that awful sequence of numbers and letters, the solution is to create an alternative user in MySQL with all admin privileges:
mysql> CREATE USER 'root'@'localhost' IDENTIFIED BY 'password'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION; mysql> FLUSH PRIVILEGES;
Finally we are able to administer the database as root with our desired password, having the Plesk control panel running smoothly with the admin user.