Backing Up Views with Mysql Dump

前端 未结 7 2457
有刺的猬
有刺的猬 2020-12-08 10:02

I want to back up only the Views with mysqldump.

Is this possible?

If so, how?

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 10:39

    I modified Andomar's excellent answer to allow the database (and other settings) to only be specified once:

    #!/bin/bash -e
    mysql --skip-column-names --batch -e \
    "select table_name from information_schema.views \
     where table_schema = database()" $* |
    xargs --max-args 1 mysqldump $*
    

    I save this as mysql-dump-views.sh and call it via:

    $ mysql-dump-views.sh -u user -ppassword databasename >dumpfile.sql
    

提交回复
热议问题