load-data-infile

How to speed up a data loading into InnoDB (LOAD DATA INFILE)?

半城伤御伤魂 提交于 2019-12-18 10:46:22
问题 I want to speed up a data loading. I use MySQL 5.5, InnoDB and have 1M rows of data (65Mb file). It takes 5 minutes. What mysql settings and commands affect the speed of LOAD DATA INFILE for InnoDB? Thank you. 回答1: I can recommend these settings to improve load time: innodb_doublewrite = 0 innodb_support_xa = 0 innodb_buffer_pool_size = (50-80% of system memory) innodb_log_file_size = (a large number - 256M etc) innodb_flush_log_at_trx_commit = 0 Other than settings, there are some things you

MySQL LOAD DATA INFILE store line number

只谈情不闲聊 提交于 2019-12-18 09:46:30
问题 I'm using MySQL LOAD DATA INFILE to move CSV file data into a database table. I'm looking for a way to reference the original file line number (row) in the imported record. So that a table like this: CREATE TABLE tableName ( uniqueId INT UNSIGNED NOT NULL PRIMARY_KEY, import_file VARCHAR(100), import_line INT, import_date = DATETIME, fieldA VARCHAR(100), fieldB VARCHAR(100), fieldC VARCHAR(100) ); Where import_file,import_line and import data are meta data relevant to the specific file import

MySQL LOAD DATA Error (Errcode: 2 - “No such file or directory”)

回眸只為那壹抹淺笑 提交于 2019-12-18 06:54:47
问题 I am trying to load data into a table of my MySQL database, and getting this error. LOAD DATA LOCAL INFILE 'C:\Users\Myself\Desktop\Blah Blah\LOAD DATA\week.txt' INTO TABLE week; Reference: this The path is hundred percent correct, I copied it by pressing shift and clicking "copy path as" and checked it many times. So any tips on this will be much appreciated . . My research: Seeing this answer, I tried by changing C:\Users to C:\\Users . It did not work for me. Secondly, is there a way to

MySQL LOAD DATA LOCAL INFILE example in python?

点点圈 提交于 2019-12-18 03:56:45
问题 I am looking for a syntax definition, example, sample code, wiki, etc. for executing a LOAD DATA LOCAL INFILE command from python. I believe I can use mysqlimport as well if that is available, so any feedback (and code snippet) on which is the better route, is welcome. A Google search is not turning up much in the way of current info The goal in either case is the same: Automate loading hundreds of files with a known naming convention & date structure, into a single MySQL table. David 回答1:

Mysql permission errors with 'load data'

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 06:46:30
问题 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'@'% 回答1: Here's a thread on the MySQL forums that discusses exactly this. Here's

access denied for load data infile in MySQL

爱⌒轻易说出口 提交于 2019-12-17 06:32:09
问题 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? 回答1: 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}'

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

亡梦爱人 提交于 2019-12-17 05:39:37
问题 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

Periodically output to browser on long operation

老子叫甜甜 提交于 2019-12-13 16:37:55
问题 I'm using LOAD DATA INFILE to import 11M records and then the script continues with other operations. The import takes 10 minutes by which time the browser has given up (after 3 minutes) and I don't see the progress of the subsequent operations. Is there a way to output something to the browser periodically while this time consuming query is running. Phpmyadmin seems to do something like this and the browser doesn't time out. 回答1: Check out flush() (http://php.net/manual/en/function.flush.php

Can you define fields and values with a “LOAD DATA LOCAL INFILE” query in MySQL?

怎甘沉沦 提交于 2019-12-13 07:13:37
问题 I'm trying to import data into a MySQL table with values not defined in the input file. I have this php string concatenated query: "LOAD DATA LOCAL INFILE '".@mysql_escape_string($this->file_name). "' IGNORE INTO TABLE `".$this->table_name. "` FIELDS TERMINATED BY '".@mysql_escape_string($this->field_separate_char). "' OPTIONALLY ENCLOSED BY '".@mysql_escape_string($this->field_enclose_char). "' ESCAPED BY '".@mysql_escape_string($this->field_escape_char). "' LINES TERMINATED BY '". $this-

MySQL “LOAD LOCAL DATA INFILE”

蓝咒 提交于 2019-12-13 06:03:53
问题 I have hit a problem and i cant seem to get over it. I am taking information from a text file(two columns 29.12 23.42 for example separated by a space), using LOAD LOCAL DATA INFILE . Initially this was working with only one column in MySQL, however i have had to add an ID AUTO INCREMENT so i can use the most recent entry, in addition i want to now store the other column in my Database. Here is my code, its probably pretty obvious but I can't seem to find it: <?PHP $username = "root";