MySQL databases and users

Add a MySQL database for a site, give it users with the privileges each one needs, and look after their passwords.

4-minute read Applies to XenoPanel 1.0.0 Updated

Each server runs one MySQL 8.4 server, listening only on the server itself. Every database belongs to a site, and a database can have several users, each with its own privileges.

Add a database

Terminal
$ xenopanel db add shop --site example.com
$ xenopanel db list  # databases, their sites and sizes, and the users

New databases use utf8mb4.

Add its users

Terminal
$ xenopanel db user add shop_app --database shop --privileges app
$ xenopanel db user add shop_deploy --database shop --privileges migrate
$ xenopanel db user add shop_report --database shop --privileges read

Each user gets one preset per database:

  • full: every privilege on the database
  • app: reading and writing data, the usual choice for a site (the default)
  • migrate: app, plus changing tables, indexes, views, triggers and routines
  • read: reading only
  • custom: the privileges you list, for example custom:SELECT,INSERT

To give an existing user access to another database, run db user add again with that database. A user works from the server over both localhost and 127.0.0.1.

Passwords

XenoPanel generates each user’s password and keeps it in your Mac’s Keychain. It’s never written to a file on your Mac.

Terminal
$ xenopanel db user password shop_app --show
$ xenopanel db user password shop_app --rotate  # a new password, set on the server
$ xenopanel db user password shop_app --option-file --client acme

--option-file writes ~/.xenopanel/shop_app.cnf into the client’s home, readable only by them, so command-line tools and cron jobs can log in without the password on the command line.

Removing databases and users

  • xenopanel db remove shop makes XenoPanel forget the database; it stays in MySQL. Add --delete-data to drop it, which XenoPanel does only after a full dump into the run’s journal on the server, and reports where it is.
  • xenopanel db user remove shop_app drops the user. Its password stays in your Keychain unless you add --delete-secrets.

Before every database change, XenoPanel saves the statements that undo it in the run’s journal, so a step that fails its check is put back as it was.

Questions about XenoPanel?

Check the help pages first, or send us a message and we’ll get back to you within 24 hours.

Need help with an app or a license? Open a support ticket →

We reply within 24 hours on business days.