Jump to content

Loading data from a local infile


fredpickwick

Recommended Posts

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 :)

Link to comment
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\';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.