Skip to main content

MySQL sync user management

Users are created to access databases in a MySQL sync cluster.

Users only have access to the cluster itself—there is no access to cluster nodes, as they are managed by Servercore. By default, all users in a cluster have the same permissions.

Access to a single MySQL sync database can be granted to multiple users.

Create a user

  1. In the control panel, in the top menu, click Products and select Cloud Databases.
  2. Open the Active tab.
  3. Open the database cluster page → Users tab.
  4. Click Create user.
  5. Enter a name and password. Save the password—it will not be stored in the dashboard.
  6. Click Save.

Change a user password

After a cluster is created, the user password can be changed. Remember to update the password in your application.

  1. In the control panel, in the top menu, click Products and select Cloud Databases.
  2. Open the Active tab.
  3. Open the cluster page → Users tab.
  4. In the user's menu, select Change password.
  5. Enter or generate a new password and save the changes.

Configure database access

Grant access to a user

Access to a single MySQL sync database can be granted to multiple users.

  1. In the control panel, in the top menu, click Products and select Cloud Databases.
  2. Open the Active tab.
  3. Open the database cluster page → Databases tab → database page.
  4. In the Have access section, click Add and select a user.

The user can only connect to the database (CONNECT) and cannot perform operations on objects. To give the user access to objects, grant them the necessary privileges.

Revoke access for a user

  1. In the control panel, in the top menu, click Products and select Cloud Databases.
  2. Open the Active tab.
  3. Open the database cluster page → Databases tab → database page.
  4. In the Have access section, remove the user.

Configure user privileges

Grant privileges

You can grant privileges to users on databases and tables using the GRANT command. Privileges can be: SELECT, INSERT, DELETE, USAGE, and others.

Example of granting read access (SELECT) to the table table in the database database to user user:

GRANT SELECT ON table TO user;

Example of granting read access (SELECT) to the database database to user user:

GRANT SELECT ON database.* TO user;

Create a read-only user

  1. Create a user.

  2. Grant the user access to the database.

  3. Create another user who will have read-only (read-only) privileges.

  4. Connect to the database using the first user.

  5. Grant read-only privileges to the database for the second user:

    REVOKE ALL PRIVILEGES ON <database_name>.* FROM '<username>'@'%';
    GRANT SELECT ON <database_name>.* TO '<username>'@'%';

    Specify:

    • <database_name> — database name;
    • <username> — name of the user who will be granted read-only privileges.

Revoke privileges

You can revoke privileges from a user using the REVOKE command.

Example of revoking privileges from user user for table table and database database:

REVOKE SELECT ON table FROM user;
REVOKE SELECT ON database.* FROM user;