How to log into MySQL as root user in Plesk

- by

Plesk-LogoYou 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):

/usr/local/psa/bin/admin --show-password

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.



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

1 thought on “How to log into MySQL as root user in Plesk”

  1. If your memory is a bitch, like mine use this to access directly:

    root@server:[~]: cat /etc/psa/.psa.shadow
    $AES-128-CBC$S2oUU99k2Qs988Ds0Cmq0w==$7/Ec2BecQpaL5XpimHrPs4UWxUis509CVBseFB1+w/GjXkfDOkMYw8u7/io7YurU

    root@server:[~]: cat /root/.my.cnf
    [client]
    password=$AES-128-CBC$S2oUU99k2Qs988Ds0Cmq0w==$7/Ec2BecQpaL5XpimHrPs4UWxUis509CVBseFB1+w/GjXkfDOkMYw8u7/io7YurU
    user=admin

    root@server:[~]: mysql
    mysql>

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.