Jump to content

Archived

This topic is now archived and is closed to further replies.

fredpickwick

Loading data from a local infile

Recommended Posts

mysql> LOAD DATA LOCAL INFILE \"pet.txt\" INTO pet;

 

Could somebody please tell me where the data file \"pet.txt\" has to be for the above instruction to work?

Share this post


Link to post
Share on other sites

mysql> LOAD DATA LOCAL INFILE \"pet.txt\" INTO pet;

 

with that I believe you have to have the pet.txt in the same directory the mysql program is running in. a better way to do it would be like

 

mysql> LOAD DATA LOCAL INFILE \"/path/to/file/pet.txt\" INTO pet;

 

and make sure the permissions are set so mysql can access it.

 

if your running on windows then I think the path needs to be something like

 

mysql> LOAD DATA LOCAL INFILE \"C:\\path\\to\\file\\pet.txt\" INTO pet;

 

hope that helps :)

Share this post


Link to post
Share on other sites

How have you stored the value sin the text files

 

meaning

 

How are the fields seprated and how are the records seprated.

 

If you have it as CSV comma seprated vlaues you can try this

 

LOAD DATA INFILE \'C:\\pet.txt\' INTO TABLE pet FIELDS TERMINATED BY \',\' LINES TERMINATED BY \'n\';

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.