Backing Up Views with Mysql Dump

NOTE: This answer from Ken moved from suggested edit to own answer.

here’s a full command line example using a variant of the above

 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).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)