Access MySql without knowing the password on Plesk servers

Posted 3 years ago

This command will allow grant you access to MySql without the need for a password (from the command line) providing you’re running on a server powered by Plesk.

I’ve categorised this as “Maintenance” however you can use this in conjunction with backing up / importing databases to bypass the need for a password.

Use the below command to backup a .sql dump of your database

mysqldump -uadmin -p`cat /etc/psa/.psa.shadow` database_name > database_backup.sql

Equally, use the below command to import your database

mysql -uadmin -p`cat /etc/psa/.psa.shadow` database_name < database_backup.sql

It kind of goes without saying but, there’s a reason there’s passwords. Tread carefully when using these commands as you can easily overwrite a database you didn’t mean to