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?
mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW for dumped views, TRIGGER for dumped triggers, LOCK TABLES if the --single-transaction option is not used, and (as of MySQL 8.0.
The syntax for granting EXECUTE privileges on a function/procedure in MySQL is: GRANT EXECUTE ON [ PROCEDURE | FUNCTION ] object TO user; EXECUTE. The ability to execute the function or procedure.
It took a total of 1 minute 27 seconds to take a dump of the entire database (same data as used for mysqldump) and also it shows its progress which will be really helpful to know how much of the backup has completed.
Assuming by full dump you also mean the VIEW
s and the EVENT
s, you would need:
GRANT USAGE ON *.* TO 'dump'@'%' IDENTIFIED BY ...; GRANT SELECT, LOCK TABLES ON `mysql`.* TO 'dump'@'%'; GRANT SELECT, LOCK TABLES, SHOW VIEW, EVENT, TRIGGER ON `myschema`.* TO 'dump'@'%';
and if you have VIEW
s that execute a function, then unfortunately you also need EXECUTE
.
My own problem is: why do I need SELECT
if I only want to make a no-data dump?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With