List all mail accounts in Plesk using MySQL command

In order to list all email accounts in Plesk , first login to the server with user who has access to ‘MySQL’. Usually this is ‘root’, but depending on the setup of the server it could be different.

Connect to the Plesk database :

mysql -uadmin -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 71211 to server version: 4.1.20
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 mysql>
 Or use this lazy command to access Plesk MySQL databse which will login you to the MySQL server and will change the database automatically:
mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa

If you have chosen the first method make sure that you are going to use the correct Plesk database, list the databases and make active the ‘psa’ one as in the example bellow. If you have chosen the second one – you are already using the ‘psa’ table.

mysql> show databases
 -> ;
 +————————-+
 | Database |
 +————————-+
 | horde |
 | lucy |
 | mysql |
 | phpmyadmin_DItFrLggnXvJ |
 | phpmyadmin_ZtLmKwBWuwdF |
 | psa |
 | valuer |
 +————————-+
 7 rows in set (0.01 sec)
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>

Now to list all Plesk mail accounts, use the command in the next field.

SELECT CONCAT_WS('@',mail.mail_name,domains.name),accounts.password FROM domains,mail,accounts WHERE domains.id=mail.dom_id AND accounts.id=mail.account_id ORDER BY domains.name ASC,mail.mail_name ASC;

Just copy and paste the above line in your MySQL
The result will show all available Plesk mail accounts inside the ‘psa’ database.

 

 

Tip by Anthony Gee | Apr 2010

Scroll to Top