Created
October 11, 2011 14:38
-
-
Save lsauer/1278258 to your computer and use it in GitHub Desktop.
Importing a SQL database file without DATABASE CREATE information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//instructions are especially for mysql: | |
//lo sauer, 2011 | |
1. create the database: 'CREATE DATABASE `enzymes`;' | |
2. now either select the database with 'USE `enzymes`;' or put the same command at the beginning of your sql-file. | |
in the latter case run sqlimport which is a shortcut for the more powerful command LOAD DATA INFILE http://dev.mysql.com/doc/refman/5.1/en/load-data.html | |
' mysqlimport -u root -p --local enzymes enzymes.sql' | |
Or in mysql (e.g. mysql -u root -p) you can use the LOAD DATA INFILE Command | |
This command also allows you to directly import csv, or similarly formatted tables e.g. | |
LOAD DATA INFILE '/enzymes.txt' INTO TABLE enzymes | |
FIELDS TERMINATED BY "\n" LINES TERMINATED BY '\r\n' IGNORE 12 LINES; | |
or e.g. //LINES STARTING BY "\t"; | |
another example with the keyword local: | |
LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE tablename | |
2.x In case of a complete sql dump you can use: | |
mysql.exe" -u root -p -h localhost myDatabase < myDatabaseDump.sql | |
==LOAD DATA Command== | |
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name' | |
[REPLACE | IGNORE] | |
INTO TABLE tbl_name | |
[FIELDS | |
[TERMINATED BY 'string'] | |
[[OPTIONALLY] ENCLOSED BY 'char'] | |
[ESCAPED BY 'char'] | |
] | |
[LINES | |
[STARTING BY 'string'] | |
[TERMINATED BY 'string'] | |
] | |
[IGNORE number LINES] | |
[(col_name_or_user_var,...)] | |
[SET col_name = expr,...)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment