Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2011
    Location
    Sydney, Australia
    Posts
    58

    Unanswered: Export MySQL to a text file

    I'm trying to export my tables from my MySQL database, horsedb, to text files. I have used the following code to export the first table, horse and there were no errors indicated in processing my code. However, I can't find the text file I've created. What am I doing wrong?

    use horsedb;
    SELECT * FROM horse INTO OUTFILE 'C:\Users\Melgra\Desktop\horsefile.txt'
    FIELDS terminated by ','
    LINES terminated by '\r\n';
    Query OK, 9 rows affected (0.01 sec)

    Thank you.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by melgra70 View Post
    However, I can't find the text file I've created.
    it's on the server
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2011
    Location
    Sydney, Australia
    Posts
    58
    How do I search for the file?
    Why doesn't it save to my desktop when that's the location I indicated?

  4. #4
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Be careful on Windows machines, for \ you will need to double these \\ so C:\Users\Melgra\Desktop\horsefile.txt should read C:\\Users\\Melgra\\Desktop\\horsefile.txt or alternatively your can use single forward quote C:/Users/Melgra/Desktop/horsefile.txt
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  5. #5
    Join Date
    Mar 2011
    Location
    Sydney, Australia
    Posts
    58
    Ronan, you're a genius! You're the best!
    Thanks so much!

Posting Permissions

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