View Full Version : Load mysql from .dat file

09-06-2006, 10:35 PM
Hi, I've been following a tutorial on mysql. In one part it explains how to import a query (in a .dat file) from the command line:

1). Move the file to c:\mysql\bin.
2). Make sure MySQL is running.
3). Issue the following command
mysql employees <employee.dat

employee.dat just contains queries like this:

INSERT INTO employee_data (f_name, l_name, title, age, yos, salary, perks, email) values ("John", "Hagan", "Senior Programmer", 32, 4, 120000, 25000, "john_hagan@bignet.com");

But it doesn't seem to work when I issue the command in step 3). I just get an error 1064.
I've read that error 1064 is the result of mysql version mismatch. How do I find out the mysql version from the command line?
Is there a different/better way to get that info into my tables?

09-08-2006, 07:29 PM
Ok, sorted it. I was trying to do it form the mysql prompt. I quit that and navigated to the folder with the regular command prompt and it worked.

01-11-2007, 02:36 AM
I see that I am currently using the same tutorial that you used before. I am still having that problem. Can you help me? I am learning MySQL and i want to know how to import .dat files. I tried the usual cmd but it didnt seem to work. Thank you

01-11-2007, 05:22 PM
It was a long time ago, and I can't remember the url of the tutorial now, so can't check it.
But from what I remember, it wouldn't work innitially because I was trying to perform the import in the .dat using the command console, but with the mysql> prompt. I exited from the mysql> prompt and it worked.

Hope that helps.

01-17-2012, 02:55 AM
The link to the great command line tutorial is:


The problem you are having is due to an error in the tutorial.
The solution to the error:
Log out of mysql by typing quit.

Drop the .dat file inside your mysql bin directory.
Navigate to that bin directory using the command line.
command line should look something like this:

Then type something like this on the command line:
mysql -u root -p employees < employee.dat
(hit the 'enter' key, enter your password and the .dat file should be imported into the database table. The command line won't give you any idea that something happened so you just log back into mysql, make sure to use the database you want to check, and then type SQL (SELECT * FROM table_name). You should see all the data inserted into that table.

Hope this clears it up for you.