Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore 'views' in mysql db backup using mysqldump

Tags:

I need to ignore all view in my database and take backup using mysqldump. Currently i am using below option.

--ignore-table=view1 --ignore-table=view2 --ignore-table=view3

Is there any way to take backup omitting all views without specifying all 'view' names.?

like image 891
Poobalan Avatar asked Dec 15 '11 12:12

Poobalan


People also ask

How do I backup a view in MySQL?

To generate the backup using mysqldump, 'Select' to dump the tables, 'Show View' for views, 'Trigger' for the triggers. If you are not using —single-transaction option, then 'Lock Tables' privileges must be granted to the user. -p [password]: The valid password of the MySQL user.

Can Mysqldump lock tables?

By default, the mysqldump utility, which allows to back a MySQL database, will perform a lock on all tables until the backup is complete.

What is the difference between Mysqldump and Mysqlpump?

mysqlpump is the 4th fastest followed closer by mydumper when using gzip. mysqldump is the classic old-school style to perform dumps and is the slowest of the four tools. In a server with more CPUs, the potential parallelism increases, giving even more advantage to the tools that can benefit from multiple threads.

What permissions are needed for Mysqldump?

mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW for dumped views, TRIGGER for dumped triggers, LOCK TABLES if the --single-transaction option is not used, and (as of MySQL 8.0.


1 Answers

If the MySQL user you're using doesn't have access to read Views, then just putting an -f flag on the mysqldump command will skip them. Unfortunately, it prints a warning which might be annoying, but it will otherwise complete the dump.

like image 163
staticsan Avatar answered Sep 20 '22 09:09

staticsan