Skip to main content
MySQL sync user management
Last update:

MySQL sync user management

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

Only the cluster itself is available for users to work with — there is no access to the cluster nodes, as they are located on the Selectel side. By default, all users in the cluster have the same permissions.

You can give multiple users access to a single MySQL sync database.

Create a user

  1. In control panel go to Cloud platformDatabases.
  2. Open the Database Cluster page → tab Users.
  3. Click Create user.
  4. Enter a name and password. Save the password — it will not be stored in the control panel.
  5. Click Save.

Change user password

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

  1. In control panel go to Cloud platformDatabases.
  2. Open the cluster page → tab Users.
  3. On the menu. user select Change password.
  4. Enter or generate a new password and save the changes.

Configure database access

Grant access to a user

You can give multiple users access to a single MySQL sync database.

  1. In control panel go to Cloud platformDatabases.
  2. Open the Database Cluster page → tab Databases → database page.
  3. In the block Have access 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, give him the privileges he needs..

Remove access for a user

  1. In control panel go to Cloud platformDatabases.
  2. Open the Database Cluster page → tab Databases → database page.
  3. In the block Have access delete the user.

Customize user privileges

Grant privileges

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

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

GRANT SELECT ON table TO user;

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

GRANT SELECT ON database.* TO user;

Create a user with read-only privileges

  1. Create a user.

  2. Grant the user access to the database.

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

  4. Connect to the database with the help of the first user.

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

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

    Specify:

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

Revoke privileges

You can revoke a user's privileges with the command REVOKE.

Example of revoking a user's privilege user on the table table and the database database:

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