How to Backup view and events only in MariaDB/MySQL


As a part of a migration, We need to export MySQL events from a MariaDB 10.2 and import them to another MariaDB 10.2

Is copying the table mysql.event enough for this or is there any better way to export only events from a MariaDB database?

There are some ways to get this done and the following how to get this done:

events only:

mysqldump -A --no-data --no-create-info --skip-triggers --no-create-db \
   --events > just-events.sql

views for single database:

mysql database_name --skip-column-names  -B -e \
"show full tables where table_type = 'view'" \
| awk '{print $1}' \
| xargs -I {} mysqldump database_name {} > just-views.sql

Hope this helps


Please enter your comment!
Please enter your name here