English | 简体中文
- The RadonDB MySQL cluster has been deployed.
Run the following command, and the mysqlusers.mysql.radondb.com
CRD is displayed.
kubectl get crd | grep mysqluser
mysqlusers.mysql.radondb.com 2021-09-21T09:15:08Z
Run the following command to create a normal user named normal_user
and a superuser named super_user
. The user password is saved in the sample-user-password
Secret.
kubectl apply -f https://github.com/radondb/radondb-mysql-kubernetes/releases/latest/download/mysql_v1alpha1_mysqluser.yaml
Note: In the example, the passwords for the normal user and superuser are both
RadonDB@123
.
kubectl get mysqluser -o wide
NAME USERNAME SUPERUSER HOSTS TLSTYPE CLUSTER NAMESPACE AVAILABLE SECRETNAME SECRETKEY
normal-user normal_user false ["%"] NONE sample default True sample-user-password normalUser
super-user super_user true ["%"] NONE sample default True sample-user-password superUser
Run the following command to connect to the primary node of the MySQL cluster as super_user
.
kubectl exec -it svc/sample-leader -c mysql -- mysql -usuper_user -pRadonDB@123
Run the following command to delete the MysqlUser
CRD and the users created in the example.
kubectl delete mysqluser normal-user super-user
Parameters | Description |
---|---|
user | User name |
hosts | Hosts allowed to access; % indicates all hosts can be accessed. |
withGrantOption | Whether a user can authorize other users; default value: false |
tlsOptions.type | TLS type; valid values: NONE /SSL /X509 ; default value: NONE |
permissions.database | Authorized databases; * indicates all databases are authorized. |
permissions.tables | Authorized tables; * indicates all tables are authorized. |
permissions.privileges | Privileges |
userOwner.clusterName | Name of the cluster that the user is in |
userOwner.nameSpace | Namespace of the cluster that the user is in |
secretSelector.secretName | Name of the Secret saving the user password |
secretSelector.secretKey | Key of the Secret saving the user password |
For more details, see Account Management Statements.
Note: Modifying
spec.user
directly will create a user with the new username. To create multiple users, ensure thatmetadata.name
(CRD instance name) is consistent withspec.user
(username).