MySQL semi-sync user management
Users are created to access databases in a MySQL semi-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 one MySQL semi-sync database.
Create a user
- В control panels go to Cloud platform → Databases.
- Open the Database Cluster page → tab Users.
- Click Create a user.
- Enter a name and password. Save the password — it will not be stored in the control panel.
- Click Save.
Change user password
After the cluster is created, the user password can be changed. Remember to change the password in your application.
- В control panels go to Cloud platform → Databases.
- Open the cluster page → tab Users.
- On the menu. user select Change password.
- 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 one MySQL semi-sync database.
- В control panels go to Cloud platform → Databases.
- Open the Database Cluster page → tab Databases → database page.
- 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
- В control panels go to Cloud platform → Databases.
- Open the Database Cluster page → tab Databases → database page.
- 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
-
Grant the user access to the database.
-
Create another user who will have read-only privileges.
-
Connect to the database with the help of the first user.
-
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;