вторник, 25 мая 2010 г.

How can I change/repair my Admin account if the password got lost?

Symptomps

If some of the following messages appear:


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 you can use the following solutions in order to solve the issue. The example shown below is for RedHat-like operating systems (RedHat, CentOS, FedoraCore). In case of other operating systems, the paths to mysql binaries may differ.

Resolution

  1. First try to restart Parallels Plesk Panel:

# /etc/init.d/psa restart

2. Check that the /etc/psa/.psa.shadow file has valid permissions. The right permissions would be

# ls -la /etc/psa/.psa.shadow
-rw------- 1 psaadm psaadm 5 Feb 26 11:22 /etc/psa/.psa.shadow

In case you have any other permission, you should change it using the following command:

# chown psaadm:psaadm /etc/psa/.psa.shadow
# chmod 600 /etc/psa/.psa.shadow

3. Check 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 get this output, it means that the Mysql server is already running.

To check that Mysql server is running fine, try to access to the 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 it will appear the following error message:

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

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

4. In the newest versions of Parallels Plesk Panel, the password can be restored using the "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 a command like the following one:

# export PSA_PASSWORD='NEW_PASSWORD' ; /usr/local/psa/admin/sbin/ch_admin_passwd; unset PSA_PASSWORD

Where you have to replace NEW_PASSWORD by the desired password for the Parallels Plesk Panel administrator.

If you do not see this utility in the version of your Parallels Plesk Panel, then the password can be synchronized manually.

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

b) Restart MySQL with the following command prompt:

# /etc/init.d/mysqld restart

c) Add the new password to the /etc/psa/.psa.shadow file.

d) Repair the password using the following command prompt:

# /usr/bin/mysql -D mysql -e"update user set password=PASSWORD('`cat /etc/psa/.psa.shadow`') where User='admin';"

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

f) Restart MySQL.


original