Im having trouble importing the text file from my desktop into the database,i tried it both ways but it doesn't seem to work, does the file have to be somewhere specifically for it to import. please help

load data local infile 'userdata_import.txt' into table tags fields terminated by ',' lines terminated by '\n';

load data local infile 'C:\Users\duy\Desktop\userdata_import.csv' into table tags
    -> fields terminated by ',' lines terminated by '\n';

I'm assuming you've already checked that local-infile is allowed for both the client and the server.

The path for the file is relative to where the mysql client is started. Since it looks like you're using Windows that's probably not where you're keeping your files so using full path instead of relative path is best.

Use forward slashes '/' or double backslashes '\\' in the filename for windows. Single backslashes are escape characters.

LOAD DATA LOCAL INFILE 'C:/Users/duy/Desktop/userdata_import.csv' INTO TABLE tags FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
or
LOAD DATA LOCAL INFILE 'C:\\Users\\duy\\Desktop\\userdata_import.csv' INTO TABLE tags FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.