'Ignore schema in MySQL dump
Is there a way to restrict/not include multiple schema from the mysqldump command? Here is my script
mysqldump -h localhost -u username -p > database_schema.sql
Thanks guys.
Solution 1:[1]
This is from mysqldump --help:
Dumping structure and contents of MySQL databases and tables.
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
If you're trying to dump only one database, then you can just specify that as the last parameter of the call. This dumps a database named "happy"
mysqldump -uroot -pPassword happy
If you want more than one database use the --databases flag. This dumps two databases, one named happy, the other named "joy_joy"
mysqldump -uroot -pPassword --databases happy joy_joy
If you'd like all databases, then specify --all-databases. This command would give you happy, joy_joy, and whatever other DBs are on your server.
mysqldump -uroot -pPassword --all-databases
As far as I know, the only way to restrict the number of tables in a mysqldump is by using the mysqldump [OPTIONS] database [tables] option.
Solution 2:[2]
--no-create-info is an option you can provide to the mysqldump program.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | cwallenpoole |
| Solution 2 |
