$ mysqldump <mysqldump options> [<dbname1> <dbname2> ...] [> outputfile.sql]
-
--all-databases Will export all databases. You don't need to provide databasenames anymore.
-
--triggers (default is True) To include triggeres in the dumped file.
-
--routines (default is False) To include routines (procedures, functions, etc.) in the dumped file.
-
--events
-
--tz-utc (defaults to True) Setting session timezone to UTC (+00:00) to export (and later import) dates to/from UTC timezone.
-
--result-file=... The filepath/name to write the resulting sql queries, instead of STDOUT. If usign this option, there is no need to redirect command output to a file anymore.
-
--no-data To only export structure and no data.
In dumped file, thre are 'definer' fields for each view/routine/etc. This may result in issues when importing the dumped file into mysql/mariadb again. To fix the issue, the definer section of queris shouls be removed:
Using mysqlpump instead of mysqldump, which has a --skip-definer
option:
$ mysqlpump --skip-definer ...
Note that this option is not available for mysqldump
After generating dump file using mysqldump, remove the definer fields using this CLI command:
$ sed 's/\sDEFINER=`[^`]*`@`[^`]*`//g' -i oldfile.sql