into-outfile

How can I have MySQL write outfiles as a different user?

雨燕双飞 提交于 2019-12-03 05:51:12
I'm working with a MySQL query that writes into an outfile. I run this query once every day or two and so I want to be able to remove the outfile without having to resort to su or sudo. The only way I can think of making that happen is to have the outfile written as owned by someone other than the mysql user. Is this possible? Edit: I am not redirecting output to a file, I am using the INTO OUTFILE part of a select query to output to a file. If it helps: mysql --version mysql Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (x86_64) using readline 5.2 The output file is created by the mysqld process

Show Databases/Tables INTO OUTFILE

≯℡__Kan透↙ 提交于 2019-11-30 21:22:48
Is there a way of getting the output of a SHOW DATABASES or SHOW TABLES command to output to a text file, similar to how the SELECT ... INTO OUTFILE works? The INTO OUTFILE produces a syntax error when used on a SHOW command. I am open to external commands if there is a way to produce this using a cmdline tool such as mysqldump. The best way to output this would be to pipe the data to a file. For instance: mysql -u root -e "SHOW DATABASES" > my_outfile.txt @Velko's answer is a good answer but only if you can access the server file system. If the server is on a different system than the client,

exporting a table in MySQL with columns that have newline characters

只愿长相守 提交于 2019-11-30 19:09:20
I am pretty inexperienced in SQL, so there should be a simple solution to my problem: I am selecting a table into a comma-separated file, and the column of type TEXT has newline characters, so when I try to import my csv into Excel, it creates separate rows each piece of text following a newline character. Here is my query: SELECT * FROM `db`.`table` INTO OUTFILE 'c:\\result.txt' FIELDS TERMINATED BY ',' ESCAPED BY '\\' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n' ; and then in Excel I import as a comma separated file which causes issues for column that has text with newline

SELECT INTO OUTFILE can't write to file

人盡茶涼 提交于 2019-11-30 19:07:30
I'm trying to do a SELECT INTO OUTFILE and I'm getting the following error: General error: 1 Can't create/write to file '/home/jason/projects/mcif/web/downloads/dump.csv' (Errcode: 13). Failing Query: " SELECT name INTO OUTFILE '/home/jason/projects/mcif/web/downloads/dump.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM account a I know what the problem probably is: my downloads folder isn't writable by my MySQL user. I don't know how to solve this problem for two reasons: I don't know how to find out what the MySQL user is I don't know how to add the MySQL user to the users who

Query output to a file gives access denied error

跟風遠走 提交于 2019-11-30 06:47:23
I am trying to capture the output of a SQL query in MySQL, to a text file using the following query. select count(predicate),subject from TableA group by subject into outfile '~/XYZ/output.txt'; I get the following error. ERROR 1045 (28000): Access denied for user 'username'@'%' (using password: YES) Any idea, where am I going wrong? Is it some permission related issue? Fire Crow Outfile is it's own permission in mysql. If you have ALL it's included. But if you just have a safe collection such as SELECT, INSERT, UPDATE, DELETE, DROP, CREATE, but not OUTFILE, "into outfile" will not work in

Show Databases/Tables INTO OUTFILE

醉酒当歌 提交于 2019-11-30 05:04:35
问题 Is there a way of getting the output of a SHOW DATABASES or SHOW TABLES command to output to a text file, similar to how the SELECT ... INTO OUTFILE works? The INTO OUTFILE produces a syntax error when used on a SHOW command. I am open to external commands if there is a way to produce this using a cmdline tool such as mysqldump. 回答1: The best way to output this would be to pipe the data to a file. For instance: mysql -u root -e "SHOW DATABASES" > my_outfile.txt @Velko's answer is a good

mysql dump to localhost outfile from a remote database

我只是一个虾纸丫 提交于 2019-11-30 03:43:27
I'm stuck. I basically want to create a LOCAL data file (csv file) from a remote database using the OUTFILE command. I am basically, pulling data.. and want to create it on my local file server vs. creating the outfile on the remote server. I'm limited on space remotely, thus I want to create the file locally. What am I missing on how to do this? Thanks! This is my working syntax so far on the command line (it is creating the file I want, but on the remote server) mysql -u test -pfoo --database test -h testdb201.name.host.com --port 3306 -ss -e "SELECT 'a','b','c' UNION SELECT col1, col2, col3

SELECT INTO OUTFILE can't write to file

﹥>﹥吖頭↗ 提交于 2019-11-30 03:21:40
问题 I'm trying to do a SELECT INTO OUTFILE and I'm getting the following error: General error: 1 Can't create/write to file '/home/jason/projects/mcif/web/downloads/dump.csv' (Errcode: 13). Failing Query: " SELECT name INTO OUTFILE '/home/jason/projects/mcif/web/downloads/dump.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM account a I know what the problem probably is: my downloads folder isn't writable by my MySQL user. I don't know how to solve this problem for two reasons: I don

MySQL SELECT INTO OUTFILE to a different server?

早过忘川 提交于 2019-11-29 07:12:04
I have a shell script on server a. The script spits out a csv file to a local directory. The problem is the database server is on server b. How do I use select * into outfile in a setup like this? I get Can't create/write to file '/home/username/test.csv/' (Errcode: 2) Solved load data infile by using 'LOCAL' keyword. Is there something like that for outfile? select into outfile can only create the file on the server, not the client. Here's what the manual recommends for your situation: If you want to create the resulting file on some client host other than the server host, you cannot use

mysql dump to localhost outfile from a remote database

别来无恙 提交于 2019-11-29 01:16:21
问题 I'm stuck. I basically want to create a LOCAL data file (csv file) from a remote database using the OUTFILE command. I am basically, pulling data.. and want to create it on my local file server vs. creating the outfile on the remote server. I'm limited on space remotely, thus I want to create the file locally. What am I missing on how to do this? Thanks! This is my working syntax so far on the command line (it is creating the file I want, but on the remote server) mysql -u test -pfoo -