Questions tagged [into-outfile]

MySQL's `SELECT ... INTO OUTFILE` command lets you quickly dump the results of a MySQL query into a file on the MySQL server. It generally should not be used for production use.

MySQL's SELECT ... INTO OUTFILE command lets you quickly dump the results of a MySQL query into a file on the MySQL server. It generally should not be used for production use.

From the MySQL documentation

The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected rows to a file. The file is created on the server host, so you must have the FILE privilege to use this syntax. file_name cannot be an existing file, which among other things prevents files such as /etc/passwd and database tables from being destroyed.

One must be able have access to the MySQL server machine, and permissions to operate on files as the mysql user in order to access and manage the dump files. These restrictions mean the SELECT ... INTO OUTFILE command is generally suitable only for testing and debugging.

If you want a dump of a table from a MySQL database on your client machine, you can call the mysqldump binary on the client. If you want a CSV of the results of a MySQL query, you generally need to roll your own code to create that file in your client application, though there are libraries that can help with the CSV format.

139 questions
0
votes
1 answer

Weird problems with mysql outfile under FreeBSD

(See my answer below. Leaving this up in case it helps someone else.) What follows is a series of attempts to dump a query to an outfile on a new FreeBSD box that my site has moved to. The results are the same if I log in as me or if I log in as…
jerrygarciuh
  • 21,158
  • 26
  • 82
  • 139
0
votes
0 answers

MySQL performance between SELECT INTO OUTFILE vs creating file programmatically from result

Is there any significant difference between saving records into file by executing SELECT INTO OUTFILE vs executing SELECT query within application and iterate through results and appending to file. Assuming server and client are on the same machine…
marcin_koss
  • 5,763
  • 10
  • 46
  • 65
0
votes
0 answers

Why does MySQL Select into outfile generate access error?

My question may really be, why can't MySQL write to /tmp. The server version is : Server version: 5.1.73 Source distribution Here are the details: I have looked through some of the suggested posts that popped up when I wrote the title to this post.…
octopusgrabbus
  • 10,555
  • 15
  • 68
  • 131
0
votes
1 answer

Using Prepare and Execute

I have a table that has training records. Each record has a field with an Agency value. I have another table of just agency values. I want to export the records into CSV files for each agency. There are over 2 million records so I don't want to…
0
votes
1 answer

Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in PHP

mysql_connect("localhost","root",""); mysql_select_db("hitnrunf_db"); $result=mysql_query("select * from jos_users INTO OUTFILE 'users.csv' FIELDS ESCAPED BY '""' TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'…
pmms
  • 183
  • 2
  • 5
  • 17
0
votes
2 answers

MySQL save INTO OUTFILE on Local Machine

I have a SQL connection to a remote SQL server and would like to run a query where the results are stored in a outfile. The problem is i want to have the file saved locally on my machine. How would i go about doing that?
Stroes
  • 351
  • 2
  • 5
  • 23
0
votes
4 answers

Access denied error on select into outfile using Zend

I'm trying to make a dump of a MySQL table on the server and I'm trying to do this in Zend. I have a model/mapper/dbtable structure for all my connections to my tables and I'm adding the following code to the mappers: public function dumpTable() { …
Peter
  • 1,211
  • 4
  • 17
  • 32
0
votes
1 answer

MySQL Outfile very slow

this is my first post and i really need help with this...... i got this escenario.... Export data from dbf files Save dbf files data into plain file with all values delimited by "," Then i depurate the data and take only the fielda i need Take…
0
votes
1 answer

Parsing the output of SELECT INTO OUTFILE

I'm trying to parse the CSV output of SELECT INTO OUTFILE. (The purpose is to bulk-load the data into an external NoSQL database; the bulk loader requires a specific file format so I'm writing a generator) My main problem is the handling of escaped…
PJ.
  • 1,196
  • 2
  • 12
  • 25
0
votes
1 answer

Writing values with no decimal points to another file using outfile

bellow is a code that takes values from two txt files to make another txt file plate1, mjd1, fiber1, d1, pval1 = np.loadtxt('combine3ga.txt', unpack='True') plate2, mjd2, fiber2, d2, pval2 = np.loadtxt('combine4ga.txt', unpack='True') with…
user1821176
  • 1,141
  • 2
  • 18
  • 29
0
votes
1 answer

how to export table into flat file with different name in mysql?

I am exporting a table using - SELECT * INTO OUTFILE 'd:\\result.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM result; Now I want to run this script daily by putting it in procedure. And I want use file…
Aamir
  • 738
  • 2
  • 17
  • 41
0
votes
1 answer

How to use SELECT INTO OUTFILE to write to a directory other than /tmp?

I'm trying to use SELECT INTO OUTFILE to write a file to a custom directory inside another directory that is one level above my document root. I can write to /tmp so I know everything else is working. I'm using the absolute full path to the file.…
toxalot
  • 11,260
  • 6
  • 35
  • 58
0
votes
0 answers

Update a file using mysql

I've a database and im trying to export the data from a table to a .csv file so that i can import the data as contact data. I can create the file and write to it using this syntax: SELECT E_Name, Email INTO OUTFILE '/xampp/tmp/result.csv' FIELDS…
Andrew Glass
  • 423
  • 2
  • 7
  • 18
0
votes
1 answer

" INTO OUTFILE " statement terminated without completion locks the file

i am creating a csv by using "INTO OUTFILE" statement for a mysql database. the database is huge 0.4 million records. i am using java program from eclipse to connect to mysql database and give this OUTFILE query. sometimes after running the query…
silverkid
  • 9,291
  • 22
  • 66
  • 92
0
votes
1 answer

mysql select into outfile text file tab seperated with line breaks

ive been trying to find someone with similar problem but without luck so im opening a new questions. I have a simple select statement that generates a text file. SELECT '1','2' UNION all SELECT Column1, Column2 INTO OUTFILE '/path/file.txt' FIELDS…
Mad Dog Tannen
  • 7,129
  • 5
  • 31
  • 55
1 2 3
9
10