snippetsqlMinor
How to import only a specific database from a .sql file?
Viewed 0 times
filehowsqldatabasespecificfromonlyimport
Problem
I have a file
How to import only
Won't:
import all databases?
dump.sql with many databases in it: mydb1, mydb2, mydb3, etc.How to import only
mydb3 and not the other databases?Won't:
mysql> create database mydb3;
mysql> use mydb3;
mysql> source /path/to/dump.sql;import all databases?
Solution
You can use the --one-database option or
Note that the documentation page in the link above states:
This option is rudimentary and should be used with care.
However, I think dump files created by mysqldump should be safe enough.
Note: this doesn't run the actual
-o for short:mysql ... -o mysb3 < /path/to/dump.sqlNote that the documentation page in the link above states:
This option is rudimentary and should be used with care.
However, I think dump files created by mysqldump should be safe enough.
Note: this doesn't run the actual
CREATE DATABASE ... statement, so you have to do that before you import.Code Snippets
mysql ... -o mysb3 < /path/to/dump.sqlContext
StackExchange Database Administrators Q#303511, answer score: 5
Revisions (0)
No revisions yet.