Import Database Schema

I have a mysqldump file that contains a schema as well as a data dump.

I need to import only the database schema from my sqldump. I tried the following command:

mysql -uUSER -pPASSWORD < filename.sql

but without help. it imports both the schema and the data.

How can i do this?

+3
source share
4 answers

IMHO, the easiest solution is to simply open the dump in a regular text editor and copy the statements CREATE TABLE ...to another file. I would not even want to do anything else.

If this is not an option for any reason, you can simply create a new dump and this time separate the structure and data in two files.

, MySQL, , GUI, HeidiSQL, .

+1

, , , .

, , , -no-data:

mysqldump -u username -p -h localhost –no-data database_name > dump.sql

+2

, , , ,

grep -ve '^INSERT' dump.sql > dump-no-data.sql

.

+2

:

mysql -u USER -pPASSWORD database < database_schema.sql
+1

All Articles