List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:July 31 2012 9:36am
Subject:Re: Exporting to CSV. Error Code: 2013. Lost connection to MySQL
server during query
View as plain text  
Hi!

>>>>> "Fred" == Fred G <Fred> writes:

Fred> Thanks Dhaval.  Putting the join condition before INTO outfile doesn't seem
Fred> to work, either.

Fred> When I try to use the same outfile name 'test123.csv' I get Error Code:
Fred> 1086 File 'test123.csv' already exists.  But then when I try to find the
Fred> csv file on my computer, there is a folder with that name, but weird files
Fred> in it, none of which are a csv-- and certainly not in the location that I
Fred> thought it would be (the same directory that the .sql query is in).

It's the mysqld server that is writing the .csv file. This means that
the path is related to the mysql data directory and not to where your
.sql file is.

When using select into outfile it's always best to give a full path!


Fred>  Additionally, when I try to identify a different path, such as 'C:\\' etc,
Fred> I get an error.  This error is: Error Code: 1. Can't create/write to file
Fred> "C:\test123.csv"(Errocde: 2).

This probably means that you don't have write access to C:\


Fred> I tried running the query outputting to a different named .csv file, but it
Fred> is still just "running..." and seems like it was like yesterday where after
Fred> 10 minutes I will get the Error that the MySQL connection was lost.

The reason that your connection is lost are ether:
- There is timeout in the client you are using
  (The server never gives a timeout for running queries).
- The mysqld server died (not likely but possible).
- Some process in your system is killing quries that runs too long.

One way to quickly check that things are working are by adding LIMIT 1
to the query.

Fred> Does anyone have an idea of what is going on?

>>> The query without exporting the file works fine, in about 12 sec/77 sec.
>>> I
>>> read online how to export MySQL queries into csv's, and I'm not sure what
>>> I
>>> am doing wrong.  I keep getting the error:
>>> Error Code: 2013.  Lost connection to MySQL server during query, where the
>>> duration/fetch values are 600.547 sec (~10 minutes).

What is the exact error message?
Which client are you using to do the query?

It's strange that the query works fine when you are not using select
into outfile.

What MySQL version are you using

Regards,
Monty
Creator of MySQL and MariaDB
Thread
Exporting to CSV. Error Code: 2013. Lost connection to MySQL serverduring queryFred G25 Jul
  • Re: Exporting to CSV. Error Code: 2013. Lost connection to MySQLserver during queryDhaval Jaiswal26 Jul
    • Re: Exporting to CSV. Error Code: 2013. Lost connection to MySQLserver during queryFred G26 Jul
      • Re: Exporting to CSV. Error Code: 2013. Lost connection to MySQLserver during queryMichael Widenius31 Jul
        • Re: Exporting to CSV. Error Code: 2013. Lost connection to MySQLserver during queryFred G1 Aug
    • Re: Exporting to CSV. Error Code: 2013. Lost connection toMySQL server during queryhsv26 Jul
      • Re: Exporting to CSV. Error Code: 2013. Lost connection to MySQLserver during queryFred G26 Jul