Question
How to connect to MySQL and open the Plesk psa database?
Answer
Note: This guide is intended for Plesk administrators with SSH/RDP access to the server.
Â
Â
In Plesk Onyx/Plesk 12.x, use the plesk db
utility:
-
To access Plesk database in MySQL:
[[email protected]]# plesk db
Once you are logged in, start running SQL queries.
Example of an SQL query:
MYSQL_LIN: mysql> select id,name from domains where name=’example.com’;
+—-+————-+
| id | name    |
+—-+————-+
| 3Â | example.com |
+—-+————-+To exit MySQL, run the command:
MYSQL_LIN: mysql>Â quit
Â
-
To run a query to Plesk database without logging in to MySQL:
[[email protected]]# plesk db “your_query_here“
Example:
[[email protected]]# plesk db “select id,name from domains where name=’example.com'”
+—-+————-+
| id | name    |
+—-+————-+
| 3Â | example.com |
+—-+————-+
Â
In Plesk 11.x and previous releases, use the following command:
-
To access Plesk database in MySQL:
[[email protected]]# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa
-
To run a query to Plesk database without logging in to MySQL:
[[email protected]]# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa -e “select * from <table>”
Â
Â
Â
On Windows Server, Plesk uses two MySQL instances:
- Plesk SQL Server on port 8306: for Plesk databases psa and apsc
- MySQL server</…