Mysql> CREATE ROLE IF NOT EXISTS OK, 0 rows affected, 1 warning (0. Mysql> CREATE ROLE 1396 (HY000): Operation CREATE ROLE failed for you use the IF NOT EXISTS clause along with the CREATE ROLE statement as shown below a new role will be created and if a role with the given name, already exists the query will be ignored. Mysql> CREATE ROLE OK, 0 rows affected (0.16 sec) CREATE DATABASE IF NOT EXISTS databasename CHARACTER SET charsetname COLLATE collationname In this syntax, First, you need to specify the database name which needs to be created after the CREATE DATABASE keywords. If you try to create a role with an existing name an error will be generated − Syntax The basic syntax of the MySQL CREATE DATABASE is as follows. Mysql> CREATE ROLE 'MyAdmin', 'MyDeveloper' You can also create multiple roles at once as shown below − Mysql> CREATE ROLE OK, 0 rows affected (0.14 sec) You can create a role by specifying the host − Mysql> GRANT 'TestRole_ReadOnly' TO OK, 0 rows affected (0.13 sec) Mysql> CREATE USER IDENTIFIED BY 'password' Then, you can GRANT the created role to a user as follows − Now, let’s grant read only privilege to the created role using the GRANT statement as − Exampleįollowing query creates a role named TestRole_ReadOnly. Where, desiredname is the name of the role you need to create. Syntaxįollowing is the syntax of the CREATE ROLE Statement − To create a role, you need to have CREATE ROLE or CREATE USER privilege. You can create one or more roles in MySQL using the CREATE ROLE statement. A role in MySQL is a set of privileges with name.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |