How to log into MySQL as root user in Plesk
You may have noticed that there is no MySQL root user on servers running Plesk. That’s because Plesk renames this user into “admin” by default – for security reasons.
The password for the admin MySQL account is the same as for the Plesk Panel admin account.
Even so, when you try to login to MySQL – remotely or locally – you may be puzzled to find that your admin password doesn’t seem to work. Let me assure you of your sanity and your keyboard skills: it’s because Plesk encrypts the password in the database.
It is the encrypted version that you must present to MySQL, not the clear version. For example, if your password was indeed “password”, then the following command will not grant you access to MySQL:
mysql -u admin -ppassword
You can check your unencrypted password by issuing the following command (on Linux servers):
In our example, it will indeed show “password” – so why doesn’t it work? It’s because that command will unencrypted the password for us. MySQL however needs the encrypted version. Here’s how we can extract this from Plesk:
cat /etc/psa/.psa.shadow // will show you something like $AES-128-CBC$w78TYgIfzDsKjOvEqkg/nQ==$O4xPUtsQe1TI3P601wQgYw==
This will give you a weird looking output as shown above. Believe it or not, that’s your MySQL admin password!
If you’re already logged into your server as root and want to issue a MySQL shell command, you can login to MySQL like so:
mysql -uadmin -p`cat /etc/psa/.psa.shadow` Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4231837 Server version: 5.5.36-cll-lve MySQL Community Server (GPL) by Atomicorp Copyright (c) 2000, 2014, 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>
If you’re attempting a remote connection to MySQL then simply paste that cryptic looking password you got in the earlier step.