i am new to the databases and i recently downloaded mysql 5.1 and learning the commands from a website. i am not able to insert the data from a file into a database. i am using the command line and typed the same command from
http://www.webdevelopersnotes.com/tutorials/sql/mysql_course_inserting_data_in_mysql_tables.php3
but it was issuing an error.. i am using windows 7.. is the file format not supported ? or the command is wrong? please help… thanks in advance
the file name is “nit.dat”… created the database named ‘nitish’ and a table inside it named ‘stud’ now i typed
mysql nitish < nit.dat ;
at the command line… and i kept the file nit.dat in the bin directory…. the file contains three records to be inserted…..
insert into stud ( id, name, age ) values ( 99, “nit”, 23);
insert into stud ( id, name, age ) values (22, “nit22”, 12);
insert into stud ( id, name, age ) values (10, “nit10”, 56);
i am prompted with an error message showing…
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that …. what to do?
corresponds to your MySQL server version for the right syntax to use near 'mysql
nitish < nit.dat' at line 1
Hmmm..I think I got it. Are you running MySQL already before executing that statement? In that case, the command fails. You need not have to connect to mysql and execute that query.
Refer this. The command is correct and it should work if the text file contains the INSERT query you have specified. If there is anything more then because of those query it should fail.
If you are a MySQL beginner you could try GUI tools where you don’t have to worry about commands 🙂 Read this. You could try SQLyog which is simple and efficient.