Using mysqldump I can backup my database. But my database has a lot of views with huge amount of data which I dont need. I only want to backup the real tables with data.
Currently I'm doing:
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
Is there a way to backup only the real tables without the views?
Views don't store any data in MySQL. View are like stored queries, not stored data. There is no content to the view, and it will not increase the size of your backup more than the size of the definition of the view. That is, the CREATE OR REPLACE VIEW
statement is the only thing that ends up in your mysqldump output related to that view.
But to answer your question: no, there's no specific option to exclude all views.
You can exclude individual names (whether they are tables or views) with the --ignore-table=db.table
option. But you'd have to list every view individually.
Another option is to mysqldump with a user who lacks the SHOW VIEW
privilege. This will exclude views from the backup, but will generate an error. You can skip errors and continue the backup if you use the --force
option.