Results 1 to 5 of 5

Thread: Load mysql from .dat file

  1. #1
    Join Date
    Sep 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Load mysql from .dat file

    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:
    Code:
    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?

  2. #2
    Join Date
    Sep 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  3. #3
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  4. #4
    Join Date
    Sep 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,
    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.

  5. #5
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Answer to problem

    The link to the great command line tutorial is:

    http://www.webdevelopersnotes.com/tutorials/sql/mysql_course_inserting_data_in_mysql_tables.php3

    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:
    C:\xampp\mysql\bin>

    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.
    Last edited by djr33; 01-17-2012 at 03:19 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •