user2373405
user2373405

Reputation: 91

Import Data from TXT file to MySQL

i have a txt file with around 0.8 million rows in it. i want to import it into SQL. i have tried converting it into CSV as well. but excel is not allowing 0.8 million rows at a time.

Upvotes: 1

Views: 465

Answers (3)

Tim Withers
Tim Withers

Reputation: 12069

Use mysqlimport

Something like

mysqlimport --columns='co_no,pd_ch' my_db sample.txt

Probably have to play around with it to get it working.

Upvotes: 2

hd1
hd1

Reputation: 34677

Try a simple LOAD DATA command. Assuming your example data is in sample.txt and you have the necessary permissions, it should be accomplished from the shell as:

LOAD DATA INFILE 'sample.txt' INTO TABLE sqlTable FIELDS TERMINATED BY ',' ENCLOSED BY '"'

Upvotes: 3

isaach1000
isaach1000

Reputation: 1839

Using MySQL Workbench will help you a lot. If you need to modify the file first, use a scripting language such as Python. Excel is not a good option for that much data.

Upvotes: 0

Related Questions