简体   繁体   English

创建用户的数据库权限-Mysql访问权限

[英]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.

相关问题 MySQL用户创建数据库需要什么权限? - What permission is required for a MySQL user to create a database? 授予mysql用户权限的用户无法访问特定的数据库原因:java.sql.SQLException:用户的访问被拒绝 - Permission granted mysql user cannot access the particular database Caused by: java.sql.SQLException: Access denied for user 如何授予 mysql 用户在 ubuntu 上创建和删除数据库的权限 - How to give a mysql user permission to create and delete database on ubuntu 仅具有USAGE特权的新用户就可以删除表(MySQL) - New user with just USAGE previleges was able to drop a table (MySQL) 为Azure上托管的免费MySQL数据库创建新用户(root用户访问权限) - Create new user for free MySQL database hosted on Azure (root access) 完全访问用户的数据库权限错误 - permission errors on database for full access user 向MySQL用户授予CREATE TABLE权限 - Grant CREATE TABLE permission to MySQL User 在 MySQL 中创建新用户并授予它对一个数据库的完全访问权限 - Create new user in MySQL and give it full access to one database 在RDS的mysql数据库上创建用户 - Create a user on mysql database at RDS 如何在 MySQL 中仅向新用户授予少数特权(仅执行 DML 和 DDL 语句)? - How to grant only few previleges ( to execute only DML and DDL statements) to the new user in MySQL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM