Admin-Ahead Community

Linux => Control Panels => Plesk => Topic started by: rohitj on December 21, 2013, 11:22:01 pm

Title: Find all databases and login credentials using mysql query
Post by: rohitj on December 21, 2013, 11:22:01 pm
Find all databases and login credentials

If we want all the database, database name and the domain whicxh is using this database in plesk control panel, we can easily find it by executing the below query.

==========
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;
==========

Enter in to Mysql.

Code: [Select]
Plesk:~#mysql  -uadmin -p`cat /etc/psa/.psa.shadow`
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37984
Server version: 5.0.51a-24+lenny5-log (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use psa;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

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   |
+-------------+---------------+-------------+------------+
| test.tk | wordpress_e   | wordpress_5 | 1l80rQ_WYn |
+-------------+---------------+-------------+------------+


 ;)