mysqldump 转储完整模式所需的最小授权? (触发器丢失了!!)
我有一个名为 dump 的 MySQL 用户,具有以下权限:
GRANT USAGE ON *.* TO 'dump'@'%' IDENTIFIED BY ...
GRANT SELECT, LOCK TABLES ON `mysql`.* TO 'dump'@'%'
GRANT SELECT, LOCK TABLES ON `myschema`.* TO 'dump'@'%'
我想使用 dump 用户转储所有数据(包括触发器和过程)。我通过以下方式调用 mysqldump:
mysqldump -u dump -p --routines --triggers --quote-names --opt \
--add-drop-database --databases myschema > myschema.sql
转储的文件一切正常,除了触发器,它们丢失了!
如果我使用 root MySQL 用户尝试 mysqldump,触发器会正确转储:
mysqldump -u root -p --routines --triggers --quote-names --opt \
--add-drop-database --databases myschema > myschema.sql
所以,我猜这是一个权限问题...额外授予我的 转储 MySQL 用户需要正确执行完整转储吗?
I have a MySQL user called dump with the following perms:
GRANT USAGE ON *.* TO 'dump'@'%' IDENTIFIED BY ...
GRANT SELECT, LOCK TABLES ON `mysql`.* TO 'dump'@'%'
GRANT SELECT, LOCK TABLES ON `myschema`.* TO 'dump'@'%'
I want to dump all data (included triggers and procedures) using the dump user. I call mysqldump in the following way:
mysqldump -u dump -p --routines --triggers --quote-names --opt \
--add-drop-database --databases myschema > myschema.sql
Everything is OK with the dumped file except for the triggers, they are missing!!
The triggers are dumped correctly if I try mysqldump with root MySQL user:
mysqldump -u root -p --routines --triggers --quote-names --opt \
--add-drop-database --databases myschema > myschema.sql
So, I guess it is a perms issue... what are the extra grants my dump MySQL user needs for doing the full dump correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
假设完全转储还意味着
VIEW
和EVENT
,您将需要:并且如果您有执行函数的
VIEW
,那么不幸的是你还需要EXECUTE
。我自己的问题是:如果我只想进行无数据转储,为什么需要
SELECT
?Assuming by full dump you also mean the
VIEW
s and theEVENT
s, you would need:and if you have
VIEW
s that execute a function, then unfortunately you also needEXECUTE
.My own problem is: why do I need
SELECT
if I only want to make a no-data dump?我找到了我需要的额外补助!!
这里有官方文档的参考:http://dev.mysql。 com/doc/refman/5.5/en/privileges-provided.html#priv_trigger
I found the extra GRANT I needed!!
Here you have the reference on the official doc: http://dev.mysql.com/doc/refman/5.5/en/privileges-provided.html#priv_trigger
我发现,有时如果 VIEW DEFINER 用户不存在,转储会失败。
按照此处所述进行更改
I found, that sometime if VIEW DEFINER user does not exist, dump fails.
Change it, as described there
除了 Jannes 答案之外,当使用带有 --tab 选项的 mysqldump 时(产生一个 tab-每个转储表的分隔文本文件),您的 MySQL 用户还必须被授予
FILE
权限:官方文档参考: https://dev.mysql.com/ doc/refman/5.7/en/mysqldump.html#option_mysqldump_tab
本节提到:
In addition to Jannes answer, when using mysqldump with --tab option (produces a tab-separated text file for each dumped table), your MySQL user must be granted the
FILE
privilege as well:Official docs reference: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_tab
Mentioned in this section: