Use the Plesk MySQL admin in scripts and one-liners
mysqldump as admin on plesk | get plesk mysql admin password | run mysql command without password prompt plesk | mysql | mariadb | plesk | loginCaution: This command changes the system. Understand what it does before you run it.
MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysql -u admin -e 'SHOW DATABASES;'Reads the password of the Plesk database administrator from /etc/psa/.psa.shadow and passes it via MYSQL_PWD to this single call only. This also lets you use mysqldump or mysqlcheck with the admin account. The risk depends on the SQL statement being run.
Note: Security critical: the password grants full access to all databases, including the Plesk database. Never set it permanently with export, never write it into scripts other users can read, and never pass it as -p<password>, since it would then be visible in the process list.
Open question before approval: Auf aktuellem Plesk Obsidian prüfen, ob das Login per MYSQL_PWD mit dem Inhalt von .psa.shadow weiterhin funktioniert, und ob plesk db mit einer Abfrage als Argument (plesk db "SHOW DATABASES") die bessere Empfehlung ist.
Also searched as
- mysqldump as admin on plesk
- get plesk mysql admin password
- run mysql command without password prompt plesk