Backing Up Views with MySQL Dump

Arif
Dec 14, 2020

--

Here’s a full command line example using a bash script

mysql -u username INFORMATION_SCHEMA
--skip-column-names --batch
-e "select table_name from tables where table_type = 'VIEW'
and table_schema = 'database'"
| xargs mysqldump -u username database
> views.sql

This extracts all of the view names via a query to the INFORMATION_SCHEMA database, then pipes them to xargs to formulate a mysqldump command. — skip-column-names and — batch are needed to make the output xargs friendly. This command line might get too long if you have a lot of views, in which case you’d want to add some sort of additional filter to the select (e.g. look for all views starting with a given character).

Source: https://stackoverflow.com/questions/1658204/backing-up-views-with-mysql-dump

--

--

Arif
Arif

Written by Arif

Blue Team at Indonesian SOCs

Responses (1)