Jump to content

loading a file into my sql


natnat

Recommended Posts

I have just started using my sql and everything was working fine with querys, creating tables and such until i tried to create a file with values in it in notepad, save it as hsiaTest.txt, and load it into my table with this code:mysql> load data local infile "hsiaTest.txt" into table test_one;it returns...ERROR 2 (HY000): File 'hsiaTest.txt' not found (Errcode: 2)I have the file saved to the same drive where the mysql database is running from so whats the problem?

Link to comment
Share on other sites

mysql doesn't run on a 'drive' it is a stand alone server runnin gon your PC.You need to save the text file where you have the code to process it.Can oyu post your code and I will try and fix it. It is most likely just a path error.

Link to comment
Share on other sites

mysql doesn't run on a 'drive' it is a stand alone server runnin gon your PC.You need to save the text file where you have the code to process it.Can oyu post your code and I will try and fix it. It is most likely just a path error.

well, what I typed in the 1st post is the line of code. I'm using this at the DOS prompt..thats the only way my project manager will allow for now.but again it is... mysql> load data local infile "hsiaTest.txt" into table test_one;ERROR 2 (HY000): File 'hsiaTest.txt' not found (Errcode: 2)mysql> load data local infile "hsiaTest.txt" into table test_one;ERROR 2 (HY000): File 'hsiaTest.txt' not found (Errcode: 2)mysql> load data local infile "hsiaTest.txt" into table test_one;ERROR 2 (HY000): File 'hsiaTest.txt' not found (Errcode: 2)mysql> load data local infile "hsiaTest.txt" into table test_one;ERROR 2 (HY000): File 'hsiaTest.txt' not found (Errcode: 2)mysql> mysql> load data local infile "hsiaTest.txt" into table test_one;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql> load data local infile "hsiaTest.txt" into table test_one' at line 1mysql>the file is just a dummy test file i created in notepad with values formated for this table:mysql> describe test_one;+-----------+-------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-----------+-------------+------+-----+---------+-------+| name | varchar(20) | YES | | NULL | || title | varchar(20) | YES | | NULL | || extension | varchar(5) | YES | | NULL | |+-----------+-------------+------+-----+---------+-------+3 rows in set (0.01 sec)
Link to comment
Share on other sites

ok I think I see the trouble :).If you saved this text file to c:\filename.txt the in the mysql command line you need to do this.

mysql> load data local infile "C:\filename.txt" into table test_one;

give this a try and see if it works.

Link to comment
Share on other sites

I did that and it didnt work.My manger came over though and told me I needed to FTP the file to the correct directoryso i did that, i got a message saying I had syntax errors but it works now.thanks though

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...