into-outfile

MySQL SELECT INTO OUTFILE to a different server?

被刻印的时光 ゝ 提交于 2019-11-28 00:28:26
问题 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? 回答1: select into outfile can only create the file on the server, not the client. Here's what the manual recommends for your situation:

MySQL INTO OUTFILE override existing file?

家住魔仙堡 提交于 2019-11-27 19:58:02
I've written a big sql script that creates a CSV file. I want to call a cronjob every night to create a fresh CSV file and have it available on the website. Say for example I'm store my file in '/home/sites/example.com/www/files/backup.csv' and my SQL is SELECT * INTO OUTFILE '/home/sites/example.com/www/files/backup.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM ( .... MySQL gives me an error when the file already exists File '/home/sites/example.com/www/files/backup.csv' already exists Is there a way to make MySQL overwrite the file? I could have PHP

Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in PHP [closed]

风流意气都作罢 提交于 2019-11-27 08:42:48
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . mysql_connect("localhost","root",""); mysql_select_db("hitnrunf_db"); $result=mysql_query("select * from jos_users INTO OUTFILE 'users.csv' FIELDS

MySQL - SELECT * INTO OUTFILE LOCAL ?

£可爱£侵袭症+ 提交于 2019-11-27 08:33:45
MySQL is awesome! I am currently involved in a major server migration and previously, our small database used to be hosted on the same server as the client. So we used to do this : SELECT * INTO OUTFILE .... LOAD DATA INFILE .... Now, we moved the database to a different server and SELECT * INTO OUTFILE .... no longer works, understandable - security reasons I believe. But, interestingly LOAD DATA INFILE .... can be changed to LOAD DATA LOCAL INFILE .... and bam, it works. I am not complaining nor am I expressing disgust towards MySQL. The alternative to that added 2 lines of extra code and a

MySQL INTO OUTFILE override existing file?

一世执手 提交于 2019-11-27 04:25:00
问题 I've written a big sql script that creates a CSV file. I want to call a cronjob every night to create a fresh CSV file and have it available on the website. Say for example I'm store my file in '/home/sites/example.com/www/files/backup.csv' and my SQL is SELECT * INTO OUTFILE '/home/sites/example.com/www/files/backup.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM ( .... MySQL gives me an error when the file already exists File '/home/sites/example.com

MYSQL into outfile “access denied” - but my user has “ALL” access.. and the folder is CHMOD 777

一笑奈何 提交于 2019-11-27 03:11:39
Any ideas? SELECT * INTO OUTFILE '/home/myacnt/docs/mysqlCSVtest.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '*' LINES TERMINATED BY '\n' FROM tbl_property WHERE managerGroupID = {$managerGroupID} Error: Access denied for user 'asdfsdf'@'localhost' (using password: YES) Pablo Santa Cruz Try executing this SQL command: > grant all privileges on YOUR_DATABASE.* to 'asdfsdf'@'localhost' identified by 'your_password'; > flush privileges; It seems that you are having issues with connecting to the database and not writing to the folder you’re mentioning. Also, make sure you have granted

MySQL export into outfile : CSV escaping chars

心不动则不痛 提交于 2019-11-26 19:52:55
I've a database table of timesheets with some common feilds. id, client_id, project_id, task_id, description, time, date There are more but thats the gist of it. I have an export running on that table to a CSV file overnight to give the user a backup of their data. It also is used as a data import for a macro Excel file with some custom reports. This all works with me looping through the timesheets with php and printing the lines to a file. The problem is with a big database it can take hours to run which isn't acceptable. So I rewrote it with the MySQL INTO OUTFILE command and it reduced it

MySQL - SELECT * INTO OUTFILE LOCAL ?

天涯浪子 提交于 2019-11-26 17:44:39
问题 MySQL is awesome! I am currently involved in a major server migration and previously, our small database used to be hosted on the same server as the client. So we used to do this : SELECT * INTO OUTFILE .... LOAD DATA INFILE .... Now, we moved the database to a different server and SELECT * INTO OUTFILE .... no longer works, understandable - security reasons I believe. But, interestingly LOAD DATA INFILE .... can be changed to LOAD DATA LOCAL INFILE .... and bam, it works. I am not

Include headers when using SELECT INTO OUTFILE?

我的未来我决定 提交于 2019-11-26 17:10:43
Is it possible to include the headers somehow when using the MySQL INTO OUTFILE ? You'd have to hard code those headers yourself. Something like: SELECT 'ColName1', 'ColName2', 'ColName3' UNION ALL SELECT ColName1, ColName2, ColName3 FROM YourTable INTO OUTFILE '/path/outfile' matt The solution provided by Joe Steanelli works, but making a list of columns is inconvenient when dozens or hundreds of columns are involved. Here's how to get column list of table my_table in my_schema . -- override GROUP_CONCAT limit of 1024 characters to avoid a truncated result set session group_concat_max_len =

MYSQL into outfile “access denied” - but my user has “ALL” access.. and the folder is CHMOD 777

核能气质少年 提交于 2019-11-26 12:22:49
问题 Any ideas? SELECT * INTO OUTFILE \'/home/myacnt/docs/mysqlCSVtest.csv\' FIELDS TERMINATED BY \',\' OPTIONALLY ENCLOSED BY \'*\' LINES TERMINATED BY \'\\n\' FROM tbl_property WHERE managerGroupID = {$managerGroupID} Error: Access denied for user \'asdfsdf\'@\'localhost\' (using password: YES) 回答1: Try executing this SQL command: > grant all privileges on YOUR_DATABASE.* to 'asdfsdf'@'localhost' identified by 'your_password'; > flush privileges; It seems that you are having issues with