I want to dump my database with function and procedure in mysql workbench. I could dump my DB without functions and procedures.but when I try to export the data with procedures, it showed me the error like:
"mysqldump:user has insufficient privileges to show create function function name"
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.21) PROCESS if the --no-tablespaces option is not used.
Listing all functions in a MySQL database can be done using SHOW FUNCTION STATUS WHERE db = 'your_database_name'; command.
To dump a database also with stored procedures, you must grant SELECT rights to mysql.proc:
Execute this statement once as root:
GRANT SELECT ON mysql.proc to 'your-mysqldump-user';
Replace your-mysqldump-user with the real username.
Then flush the privileges:
FLUSH PRIVILEGES
Now you should be able to dump the database including stored procedures with your mysqldump-user.
UPDATE: as @Michael pointed out in the comments, FLUSH PRIVILEGES isn't nesseccary in this case
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