MySQL MySQL用户创建数据库需要什么权限?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9934447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What permission is required for a MySQL user to create a database?
提问by AKWF
Is it possible for a user other than root to create a database?
root 以外的用户是否可以创建数据库?
GRANT SELECT, CREATE ON *.* TO 'myguy'@'thatmachine' IDENTIFIED BY PASSWORD '*12057DFA2BFBD8760D4788735B1C3E26889D7ECE' |
GRANT ALL PRIVILEGES ON `db1`.* TO 'myguy'@'thatmachine'
GRANT ALL PRIVILEGES ON `db2`.* TO 'myguy'@'thatmachine'
I wonder what privilege is missing here? Also, why does the first line have a password attached to it?
我想知道这里缺少什么特权?另外,为什么第一行附加了密码?
UPDATE
更新
Let me further clarify what the point of my question is. I have two database machines, source and target. There are many customer databases on the source machine. I need to move those source databases to the other target machine.
让我进一步澄清我的问题的重点是什么。我有两台数据库机器,源和目标。源机器上有很多客户数据库。我需要将这些源数据库移动到另一台目标机器上。
The databases are in the form of mysqldump'ed .sql files, which are sftp'd from source to target. Target user, not root, must then recreate the databases locally from each .sql file, perform some actions, then drop the database.
数据库采用 mysqldump 的 .sql 文件的形式,从源到目标通过 sftp 传输。目标用户(而不是 root)必须从每个 .sql 文件在本地重新创建数据库,执行一些操作,然后删除数据库。
I can't find a way to give these privileges to the target user without giving him global privileges on *.*
, which effectively makes that user as dangerous as root.
我无法找到一种方法来将这些权限授予目标用户而不授予他对 的全局权限*.*
,这实际上使该用户与 root 一样危险。
采纳答案by Thomas Wright
回答by Nacht - Reinstate Monica
As Izkata and Evan Donovan have mentioned in the comments, the best way to achieve this is to give myguy
all privileges on the database myguy_%
.
正如 Izkata 和 Evan Donovan 在评论中提到的那样,实现这一目标的最佳方法是授予myguy
数据库的所有权限myguy_%
。
You can do this with the following sql:
您可以使用以下 sql 执行此操作:
grant all privileges on 'myguy_%'.* to myguy@localhost identified by 'password';
This way you don't have to bother with other existing databases, and myguy
is able to create new databases to his heart's content.
这样您就不必费心使用其他现有的数据库,并且myguy
能够根据自己的喜好创建新的数据库。
回答by Thomas Wright
The password field is what that particular user's password is when logging into MySQL itself. I'm not exactly sure what you mean when you say you wonder what privileges are missing. What exactly are you trying to do?
密码字段是特定用户登录 MySQL 时的密码。当您说您想知道缺少哪些特权时,我不太确定您的意思。你到底想做什么?