↑ ↓ select, Enter open, Esc close

Use the Plesk MySQL admin in scripts and one-liners

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
root@server
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

Related one-liners

All in MySQL and MariaDB

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.