• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved Database migration fails: Access denied for user 'admin'@'localhost'

Alex Kern

New Pleskian
I want to transfer my current Plesk Onyx (Version 17.0.17 Update #16) to a fresh server (with same Plesk) using the migration tool, but i always get this error:

[20 Feb 17 10:49:59] [Inhalt synchronisieren] Failed to copy content of database 'baxxxxxxel'
Migration tools tried to perform operation in 3 attempts: Command execution failed on the source server 'source' (81.169.243.140) with non-zero exit code.
command: MYSQL_PWD="$(cat)" mysqldump -h localhost -P 3306 -uadmin --quick --quote-names --add-drop-table --default-character-set=utf8 --set-charset --routines baxxxxxxel > /tmp/db-dumps/baxxxxxxel.sql
exit code: 2
stdout:
stderr: mysqldump: Got error: 1045: Access denied for user 'admin'@'localhost' (using password: YES) when trying to connect

I already followed this:
https://kb.plesk.com/de/116916 (Didn't give me the error in 5.)

Any ideas?
Thanks!

:) AK
 
Hey,

Do you get the same error if you force the password change through Plesk? If you do, try reset through cli and try again:

/usr/local/psa/bin/init_conf -u -passwd new_password
 
That won't work. Instead, make sure that the database user "admin@localhost" is set to use the password that is given in the file /etc/psa/.psa.shadow
 
I got the same problem when transfer from source Plesk 10.4.4 to‪ destination Debian 8.7 ‬Product Plesk Onyx Version 17.0.17 Update #17

Migration Error:
[Migration] Failed to copy content of database 'DBNAME'
Migration tools tried to perform operation in 3 attempts: Command execution failed on the source server 'source' (xxx.xxx.xxx.xxx) with non-zero exit code.
command: MYSQL_PWD="$(cat)" mysqldump -h localhost -P 3306 -uadmin --quick --quote-names --add-drop-table --default-character-set=utf8 --set-charset --routines DBNAME > /tmp/db-dumps/DBNAME.sql
exit code: 2
stdout:
stderr: mysqldump: Got error: 1045: Access denied for user 'admin'@'localhost' (using password: YES) when trying to connect

I am quite sure that the database user "admin@localhost" is set to use the password that is given in the file /etc/psa/.psa.shadow

And when I did on source I still got the migration error from above
/usr/local/psa/bin/admin --show-password

I did on source server:
mysql -uadmin -p`cat /etc/psa/.psa.shadow` mysql
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 13152525
Server version: 5.1.61-0+squeeze1 (Debian)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SHOW GRANTS FOR 'admin'@'localhost'\G
*************************** 1. row ***************************
Grants for admin@localhost: GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY PASSWORD 'BLABLABLA' WITH GRANT OPTION
1 row in set (0.00 sec)

mysql> GRANT GRANT OPTION ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

So how is de migration tool logging in on the source? Can I check te password that is used?
 
And did you reset the admin@localhost database password to the one stored in /etc/psa/.psa.shadow ?
 
During the investigation I have found a misconfiguration in file /usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/utils/database_utils.py .

++
Before:
line number 432: command += u'MYSQL_PWD="$(cat)" '

After:
command += u'MYSQL_PWD="$(cat /etc/psa/.psa.shadow)" '
++

The above case is already reported as bug with ID PPS-158.
 
During the investigation I have found a misconfiguration in file /usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/utils/database_utils.py .

++
Before:
line number 432: command += u'MYSQL_PWD="$(cat)" '

After:
command += u'MYSQL_PWD="$(cat /etc/psa/.psa.shadow)" '
++

The above case is already reported as bug with ID PPS-158.

so how do we make a fix?
 
i have checked the file.

Code:
command += u'MYSQL_PWD="$(cat /etc/psa/.psa.shadow)" '

The above already exist, so you are saying it should be double or what? from line 438 to 455.

Code:
command = ''
        stdin = None
        if server.host == 'localhost' and server.port == 3306:
            # a workaround for Plesk
            command += u'MYSQL_PWD="$(cat /etc/psa/.psa.shadow)" '
        elif server.password():
            command += u'MYSQL_PWD="$(cat)" '
            stdin = server.password()
        command += (
            u"mysqldump --no-defaults -h {src_host} -P {src_port} -u{src_admin} --quick --quote-names "
            u"--add-drop-table --default-character-set=utf8 --set-charset ")

        if _has_mysqldump_stored_procedures(server):
            command += u" --routines "

        command += u"{db_name} > {dump_tmpname}"
        options = self._get_dump_options(server, dump_filename)
        return command, options, {}, stdin
 
i have checked the file.

Code:
command += u'MYSQL_PWD="$(cat /etc/psa/.psa.shadow)" '

The above already exist, so you are saying it should be double or what? from line 438 to 455.

Code:
command = ''
        stdin = None
        if server.host == 'localhost' and server.port == 3306:
            # a workaround for Plesk
            command += u'MYSQL_PWD="$(cat /etc/psa/.psa.shadow)" '
        elif server.password():
            command += u'MYSQL_PWD="$(cat)" '

The second had only
Code:
  command += u'MYSQL_PWD="$(cat)" '
and need there also the
Code:
 cat /etc/psa/.psa.shadow
File, otherwise Migration failed with no access for admin@localhost
 
Back
Top