The best answer for this is probably this one
by olliiiver which I have slightly modified. It specifically exports a drop table query and a create or replace view query for every view in the system, without needing to mess around with any tables. The drop table query is often important, as mysqldump apparently likes to recreate views as tables unless you include every view in its own --ignore-table parameter, which would be annoying. It uses INFORMATION_SCHEMA.
mysql --skip-column-names --batch \
-e "SELECT CONCAT('DROP TABLE IF EXISTS ', TABLE_SCHEMA, '.', TABLE_NAME, \
'; CREATE OR REPLACE VIEW ', TABLE_SCHEMA, '.', TABLE_NAME, ' AS ', \
VIEW_DEFINITION, '; ') AS q FROM INFORMATION_SCHEMA.VIEWS"
If you want to turn something like this into a shell script, I also recommend using the --defaults-extra-file=CREDSFILENAME parameter, so that you do not need to specify user/pass in the script.
The credentials file looks like this:
[client]
username=YourUsernameHere
password=YourPasswordHere