load-data-infile

Parameterizing file name in MYSQL LOAD DATA INFILE

巧了我就是萌 提交于 2019-11-27 08:03:39
问题 Is there a way to dynamically specify a file name in the LOAD DATA INFILE? Can it be parameterized like for instance (syntax may be incorrect) LOAD DATA INFILE '$filename'? 回答1: A citation from MySQL documentation: The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. The file name must be given as a literal string. That means that it can not be a parameter of a prepared statement. But no one forbids to make the string interpolation while the statement

MySQL load data infile - acceleration?

…衆ロ難τιáo~ 提交于 2019-11-27 06:45:20
sometimes, I have to re-import data for a project, thus reading about 3.6 million rows into a MySQL table (currently InnoDB, but I am actually not really limited to this engine). "Load data infile..." has proved to be the fastest solution, however it has a tradeoff: - when importing without keys, the import itself takes about 45 seconds, but the key creation takes ages (already running for 20 minutes...). - doing import with keys on the table makes the import much slower There are keys over 3 fields of the table, referencing numeric fields. Is there any way to accelerate this? Another issue is

LOAD DATA LOCAL INFILE fails - from php, to mysql (on Amazon rds)

非 Y 不嫁゛ 提交于 2019-11-27 02:23:41
问题 We're moving our database from being on the webserver to a separate server (from an Amazon EC2 webserver to an RDS instance.) We have a LOAD DATA INFILE that worked before that is going to need the LOCAL keyword added now that the database will be on a different machine to the webserver. Testing on my dev server, it turns out that it doesn't work: I can still LOAD DATA INFILE from php as I have been I can LOAD DATA LOCAL INFILE from mysql commandline (with --local_infile=1) I can't LOAD DATA

Mysql permission errors with 'load data'

喜欢而已 提交于 2019-11-27 01:58:52
I am running into a permission error when trying to load data from a flat file database dump into a new table. I know that the schema of the file and my table is the same and I tried tweaking the permissions. What else should I try? mysql> load data infile 'myfile.txt' into table mytable fields terminated by ',' enclosed by '"'; ERROR 1045 (28000): Access denied for user 'user'@'%' grant all on mytable.* to 'user'@'% Here's a thread on the MySQL forums that discusses exactly this. Here's the answer, posted by Ken Tassell Problem resolved using the command below: grant file on *.* to kentest

access denied for load data infile in MySQL

偶尔善良 提交于 2019-11-27 00:29:33
I use MySQL queries all the time in PHP, but when I try LOAD DATA INFILE, I get the following error #1045 - Access denied for user 'user'@'localhost' (using password: YES) Does anyone know what this means? I just ran into this issue as well. I had to add "LOCAL" to my SQL statement. For example, this gives the permission problem: LOAD DATA INFILE '{$file}' INTO TABLE {$table} Add "LOCAL" to your statement and the permissions issue should go away. Like so: LOAD DATA LOCAL INFILE '{$file}' INTO TABLE {$table} Yamir Encarnacion I had this problem. I searched around and did not find a satisfactory

How to skip columns in CSV file when importing into MySQL table using LOAD DATA INFILE?

对着背影说爱祢 提交于 2019-11-26 21:42:01
I've got a CSV file with 11 columns and I have a MySQL table with 9 columns. The CSV file looks like: col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 and the MySQL table looks like: col1, col2, col3, col4, col5, col6, col7, col8, col9 I need to map the columns 1-8 of CSV file directly to the first 8 columns of the MySQL table. I then need to skip the next two columns in the CSV file and then map column 11 of CSV file to column 9 of MySQL table. At the moment I am using the following SQL command: LOAD DATA LOCAL INFILE 'filename.csv' INTO TABLE my_table FIELDS TERMINATED BY '

Error 1148 MySQL The used command is not allowed with this MySQL version

倾然丶 夕夏残阳落幕 提交于 2019-11-26 20:57:33
问题 I am using MySQL LOAD DATA LOCAL INFILE command and I get this error: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1148 The used command is not allowed with this MySQL version: LOAD DATA LOCAL INFILE '/tmp/phpI0ox54' INTO TABLE `dev_tmp` FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES; Array ( ) in dc_real_estate_form_submit() (line 147 of /PATH/TO/PHP/SCRIPT). What setting can we change to allow LOAD DATA LOCAL infile? Here is the Drupal

MYSQL LOAD DATA INFILE ignore duplicate rows (autoincrement as primary key)

空扰寡人 提交于 2019-11-26 20:25:45
问题 I ran into some trouble using LOAD DATA INFILE command as i wanted to ignore the lines that was already in the data base..say if i have a table with data as follows, id |name |age -------------------- 1 |aaaa |22 2 |bbbb |21 3 |bbaa |20 4 |abbb |22 5 |aacc |22 Where id is auto increment value. an the csv file i have contains data as follows, "cccc","14" "ssee","33" "dddd","22" "aaaa","22" "abbb","22" "dhgg","34" "aacc","22" I want to ignore the rows, "aaaa","22" "abbb","22" "aacc","22" and

Import CSV to MySQL

时光怂恿深爱的人放手 提交于 2019-11-26 20:04:26
I have created a database and a table. I have also created all the fields I will be needing. I have created 46 fields including one that is my ID for the row. The CSV doesn't contain the ID field, nor does it contain the headers for the columns. I am new to all of this but have been trying to figure this out. I'm not on here being lazy asking for the answer, but looking for directions. I'm trying to figure out how to import the CSV but have it start importing data starting at the 2nd field, since I'm hoping the auto_increment will fill in the ID field, which is the first field I created. I

Easy way to export a SQL table without access to the server or phpMyADMIN

◇◆丶佛笑我妖孽 提交于 2019-11-26 19:37:22
I need a way to easily export and then import data in a MySQL table from a remote server to my home server. I don't have direct access to the server, and no utilities such as phpMyAdmin are installed. I do, however, have the ability to put PHP scripts on the server. How do I get at the data? I ask this question purely to record my way to do it lewis You could use SQL for this: $file = 'backups/mytable.sql'; $result = mysql_query("SELECT * INTO OUTFILE '$file' FROM `##table##`"); Then just point a browser or FTP client at the directory/file (backups/mytable.sql). This is also a nice way to do