Plesk: listing all the database account info (dbname/username/password)

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, November 19, 2011

Follow me on Twitter as @mattiasgeniar

There’s no single command (yet) to list all the database users/passwords, but the information is stored in plain text in the database – so you can just retrieve them from there.

First, log into the MySQL database.

# mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa

mysql>

And copy/paste the following query into it.

SELECT domains.name AS domain_name, data_bases.name AS database_name, db_users.login, accounts.password

FROM data_bases, db_users, domains, accounts

WHERE data_bases.dom_id = domains.id

AND db_users.db_id = data_bases.id

AND db_users.account_id = accounts.id

ORDER BY domain_name;

It should look similar to this:

mysql> SELECT domains.name AS domain_name, data_bases.name AS database_name, db_users.login, accounts.password

-> FROM data_bases, db_users, domains, accounts

-> WHERE data_bases.dom_id = domains.id

-> AND db_users.db_id = data_bases.id

-> AND db_users.account_id = accounts.id

-> ORDER BY domain_name;

+-–-–-–-–-–-–+-–-–-–-–-–-–-–-–+-–-–-–-–-–-–+-–-–-–-–-–-–-—-+

| domain_name      | database_name          | login            | password              |

+-–-–-–-–-–-–+-–-–-–-–-–-–-–-–+-–-–-–-–-–-–+-–-–-–-–-–-–-—-+

| mattiasgeniar.be | mattiasgeniar_projects | mattiasg_xxxxxxx | blablabla             |

| mattiasgeniar.be | mattiasgeniar_blog     | mattiasg_xxxxxxx | blablabla             |

That could help you in troubleshooting some database issues.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.