Search code examples
mysqllinuxcentosplesk

Reset admin password for MySQL and Plesk on CentOS 6


I have updated mysql using...

wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
yum localinstall mysql57-community-release-el6-7.noarch.rpm
yum-config-manager --disable mysql57-community
yum-config-manager --enable mysql55-community
yum update mysql-server

Everything went fine. But then when I tried to update the tables etc with

mysql_upgrade -u root -p

I got

Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Error: Failed while fetching Server version! Could be due to unauthorized access.
FATAL ERROR: Upgrade failed

I tried

mysql_upgrade -uadmin -p

and

mysql_upgrade -uadmin -p`cat /etc/psa/.psa.shadow`

after reading that this was what was needed for Plesk, but it had the same result.

mysqlcheck --all-databases --check-upgrade --auto-repair

gave

mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) when trying to connect

At this point I checked passwords but I thought they were correct.

At this point I messed up when trying to change/update/reset the password in mysql. I followed code I found online...

cp /etc/psa/.psa.shadow /etc/psa/.psa.shadow.bak # just backup
chmod 400 /etc/psa/.psa.shadow.bak # just secure backup
echo "PLACE PLAIN PASSWORD OF MySQL user ADMIN HERE" > /etc/psa/.psa.shadow

and also

mysql -uadmin -p'cat /etc/psa/.psa.shadow' mysql -e "update user set Password=password('password') where User='admin'; flush privileges;"

And now I have

Unable to connect to database: mysql_connect(): Access denied for user 'admin'@'localhost' (using password: NO) (Error code: 1045) (Abstract.php:69)

when trying to connect to Plesk.

So I think now my mysql admin password and password in /etc/psa/.psa.shadow do not match? I have been trying to find how to start again by setting a mysql admin password and the same for /etc/psa/.psa.shadow, but at this point I decided to ask for help!

Is there anybody who can help me? :)


Solution

  • So I think now my mysql admin password and password in /etc/psa/.psa.shadow do not match?

    Yes, you are right.

    You can just set password for MySQL's admin user back from /etc/psa/.psa.shadow like:

    mysql -uadmin -pYouCurrentPassword -e "update user set Password=password('string from .psa.shadow') where User='admin'; flush privileges;"
    

    After this it's should be possible to login to plesk and change password to new one if you need.