[英]Create database permission to user - Mysql access previleges
I want to create multiple users on MySQL and allow them to create databases and access the databases which are only created by them. 我想在MySQL上创建多个用户,并允许他们创建数据库并访问仅由他们创建的数据库。 Is there a way to do this? 有没有办法做到这一点? If so what permission I need to give? 如果是这样,我需要给予什么许可?
Instead of giving "create database" permission to a user, from "root" you can just create the database and grant all privileges on the database to the specific users. 无需从“ root”用户授予“创建数据库”权限,您只需创建数据库并将数据库上的所有特权授予特定用户即可。 That's what I am using in my world. 那就是我在我的世界中使用的东西。 I don't think "create database" privileges available in MySQL especially. 我认为MySQL中没有“创建数据库”特权。
Using the below approach you have the control of database level because the user can do anything in the specific database where they had the permission, not at the instance level (mean they can't create junk databases). 使用以下方法,您可以控制数据库级别,因为用户可以在具有权限的特定数据库中执行任何操作,而不是在实例级别(意味着他们无法创建垃圾数据库)。
Friday 28> mysql -uroot -p
mysql> create user test identified by 'test';
mysql> create database x1;
mysql> grant all privileges on x1.* to 'test'@'%';
Friday 28> mysql -utest -p
Enter password:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| x1 |
+--------------------+
2 rows in set (0.00 sec)
mysql> use x1;
Database changed
mysql> create table test(c int);
seQuery OK, 0 rows affected (0.44 sec)
mysql> select * from test;
Empty set (0.00 sec)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.