如何创建具有有限权限的MySQL用户?
要创建具有有限特权的MySQL用户,以下是语法-
CREATE USER 'yourUserName'@'yourHostName' IDENTIFIED BY 'yourPassword';
以下是为用户设置受限特权的语法-
GRANT SELECT, INSERT, UPDATE, etc. REFERENCESON yourDatabaseName.* TO 'yourUserName'@'yourHostName';
让我们实现上述语法,以创建具有有限权限的MySQL用户-
mysql> CREATE USER 'David'@'localhost' IDENTIFIED BY 'david';mysql> GRANT SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE, REFERENCES
ON test.* TO 'David'@'localhost';
让我们检查是否已使用名称“ David”创建用户。
mysql> select user, host from MySQL.user;
这将产生以下输出-
+------------------+-----------+| user | host |
+------------------+-----------+
| Bob | % |
| User2 | % |
| mysql.infoschema | % |
| mysql.session | % |
| mysql.sys | % |
| root | % |
| @UserName@ | localhost |
| Adam Smith | localhost |
| David | localhost |
| James | localhost |
| John | localhost |
| John Doe | localhost |
| User1 | localhost |
| am | localhost |
| hbstudent | localhost |
| mysql.infoschema | localhost |
| mysql.session | localhost |
+------------------+-----------+
17 rows in set (0.00 sec)
以上是 如何创建具有有限权限的MySQL用户? 的全部内容, 来源链接: utcz.com/z/347298.html