Product:
Search Type:

How can I change/repair my admin account if the password is lost?

Article ID: 346 
Last Review: Dec,12 2007
APPLIES TO:
  • Plesk for Linux/Unix

SYMPTOMS

If you see one of the following error messages:

Unable to connect to database


login.php3: Unable to connect to database: Permission denied

ERROR 1045: Access denied for user: 'admin@localhost' (Using password: YES)

Then we can offer you the following options to solve this issue. The example below is for RedHat-like operations systems (RedHat, CentOS, FedoraCore), for other operation systems paths to mysql binaries may differ.


RESOLUTION

1. Please try to restart Plesk first:
# /etc/init.d/psa restart

2. Make sure that /etc/psa/.psa.shadow file has a valid permissions. Right permissions should be
# ls -la /etc/psa/.psa.shadow
-rw------- 1 psaadm psaadm 5 Feb 26 11:22 /etc/psa/.psa.shadow

If you have any other permissions, then you need to change it using the following command:
# chown psaadm:psaadm /etc/psa/.psa.shadow
# chmod 600 /etc/psa/.psa.shadow

3. Make sure that Mysql server is running and working properly using the "ps ax | grep mysql" command. For example:
# ps ax | grep mysql
7996 ? S 0:00 /bin/sh /usr/bin/safe_mysqld --defaults-file=/etc/my.cnf
8022 ? S 0:14 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr
--datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking

If you see this output, then it means that Mysql server is running.

To check that Mysql server is working properly, you should try to log into mysql console. For example:
# mysql -uadmin -p`cat /etc/psa/.psa.shadow` -D psa
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1299 to server version: 3.23.54

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql>


Usually the error message presented below appears:

ERROR 1045: Access denied for user: 'admin@localhost' (Using password: YES)

If you cannot log into MySQL using command line above, then the following solution will help you to repair admin account password.

4. In the last Plesk versions the password can be reset using "ch_admin_passwd" utility.
# /usr/local/psa/admin/sbin/ch_admin_passwd --help
/usr/local/psa/admin/sbin/ch_admin_passwd: Utility to set Plesk adminstrator's password
Gets password from the environment variable PSA_PASSWORD
Password should be from 5 to 14 symbols and should not contain login name, whitespace, quotes or national characters

Usage: /usr/local/psa/admin/sbin/ch_admin_passwd

  -h, --help
        display this help and exit

To change the password use the command like:
# export PSA_PASSWORD='NEW_PASSWORD' ; /usr/local/psa/admin/sbin/ch_admin_passwd; unset PSA_PASSWORD

Where NEW_PASSWORD have to be replaced with your desired Plesk administrator password.

If there is no such utility in your Plesk version, the password can be synchronizes manually.

a) Load MySQL with the 'skip-grant-tables' option by  adding skip-grant-tables into [mysqld] section of the /etc/my.cnf file

b) Restart MySQL with the command line below:
# /etc/init.d/mysqld restart

c) Put the new password into /etc/psa/.psa.shadow file.

d) Repair password with the command line below:
# /usr/bin/mysql -D mysql -e"update user set password=PASSWORD('`cat /etc/psa/.psa.shadow`') where User='admin';"

e) Remove skip-grant-tables option from /etc/my.cnf

f) Restart MySQL.
Keywords: Unable to connect to database Access denied admin@localhost cannot login into plesk cp password error

Please provide feedback on this article

Did this article help you solve your issue?
Yes
No
Partially
I do not know yet
 
Strongly Agree   Strongly Disagree
  9 8 7 6 5 4 3 2 1
The article is easy to understand
The article is accurate
Additional Comments:
*Please provide us with your email address in case we need to contact you.
*Please type the code you can see.
* - required fields