How to create and manage database users

Create database users and grant least-privilege access on TurboStack.

Create additional MySQL users with only the access they need - for example a read-only user for reporting, or a separate user per application. Your application already has a main database user; add extra users rather than sharing it.

The TurboStack way: extra database users

The simplest option is to let TurboStack manage the user for you:

  1. Open the application's Configure application dialog and go to the Database Info tab (Applications).

  2. Add an extra database user and choose its role - read-only or admin.

  3. Publish the host. TurboStack creates the user and shows its credentials on the Credentials tab.

Use this for the common cases; it keeps the user in your configuration and recreates it consistently.

Create a user by hand (SQL)

For finer-grained grants, connect over SSH as your system user and run SQL with the mysql command-line client (mysql is the client command, not a user name). Grant only what the user needs.

A read-only user on one database:

CREATE USER 'prod_readonly'@'localhost' IDENTIFIED BY 'a-strong-password';
GRANT SELECT ON prod_db.* TO 'prod_readonly'@'localhost';
FLUSH PRIVILEGES;

A user with full access to a single application database:

CREATE USER 'prod_app'@'localhost' IDENTIFIED BY 'a-strong-password';
GRANT ALL PRIVILEGES ON prod_db.* TO 'prod_app'@'localhost';
FLUSH PRIVILEGES;

Rotate a password

ALTER USER 'prod_readonly'@'localhost' IDENTIFIED BY 'a-new-strong-password';
FLUSH PRIVILEGES;

Update the password wherever the user is configured (the application, or your client) at the same time.

Verify access

SHOW GRANTS FOR 'prod_readonly'@'localhost';

Then connect as that user and confirm it can do what it should - and nothing more.