snippetMinor
how to import mysql database structure?
Viewed 0 times
databasemysqlstructurehowimport
Problem
I have a database on Machine A. What I want is to dump my database in such a way that when I import it on another machine (Machine B) only the structure of the tables and Database are created.
I want no data.
Can
I want no data.
Can
mysqldump be used here?Solution
Yes.
If you want to import the structure of the Database on some other machine there are some steps as follows
1.on Machine A(generate the dump without the data)
using
if you want only data dump do as(It will not contain the create statements)
2.copy the database_structure.sql on Machine B
Then you want to restore its structure on Machine B do
3.
Then you have database structure available on the Machine B.
try it..
If you want to import the structure of the Database on some other machine there are some steps as follows
1.on Machine A(generate the dump without the data)
mysqldump -uuser -ppass --no-data --databases db1 db2 db3 > database_structure.sqlusing
mysqldump with --no-data will generate the dump without the data. if you want only data dump do as(It will not contain the create statements)
mysqldump -uuser -ppass --no-create-info --databases db1 db2 db3 > database_data.sql2.copy the database_structure.sql on Machine B
Then you want to restore its structure on Machine B do
3.
mysql -uuser -ppass < database_structure.sqlThen you have database structure available on the Machine B.
try it..
Code Snippets
mysqldump -uuser -ppass --no-data --databases db1 db2 db3 > database_structure.sqlmysqldump -uuser -ppass --no-create-info --databases db1 db2 db3 > database_data.sqlContext
StackExchange Database Administrators Q#13905, answer score: 7
Revisions (0)
No revisions yet.