load-data-infile

PHP - Import CSV file to mysql database Using LOAD DATA INFILE

房东的猫 提交于 2019-11-26 18:47:31
I have a .csv file data like that Date,Name,Call Type,Number,Duration,Address,PostalCode,City,State,Country,Latitude,Longitude "Sep-18-2013 01:53:45 PM","Unknown","outgoing call",'123456',"0 Secs","null","null","null","null","null",0.0,0.0,,, "Sep-18-2013 01:54:14 PM","Unknown","outgoing call",'1234567890',"0 Secs","null","null","null","null","null",0.0,0.0,,, "Sep-18-2013 01:54:37 PM","Unknown","outgoing call",'14772580369',"1 Secs","null","null","null","null","null",0.0,0.0,,, and I'm using the following code to insert the data into database $sql = "LOAD DATA INFILE `detection.csv` INTO

Importing a csv into mysql via command line

守給你的承諾、 提交于 2019-11-26 15:48:12
I'm trying to import a very large .csv file (~4gb) into mysql. I was considering using phpmyadmin, but then you have a max upload size of 2mb. Someone told me that I have to use the command line. I was going to use these directions to import it: http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html#c5680 What would be the command to set the first row in the .csv table as the column names in the mysql table? This option is available through phpmyadmin, so their must be a mysql command line version too, right?. Please help me. Thank you. -Raj Balanivash Try this command load data local infile

How to change string date to MySQL date format at time of import of CSV using MySQL's LOAD DATA LOCAL INFILE

廉价感情. 提交于 2019-11-26 14:21:14
问题 I'm using MySQL's LOAD DATA LOCAL INFILE SQL statement to load data from a CSV file into an existing database table. Here is an example SQL statement: LOAD DATA LOCAL INFILE 'file.csv' INTO TABLE my_table FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (name, address, dateOfBirth) The third column in the CSV that maps to the dateOfBirth field currently has the date in the following format: 14-Feb-10 How can I modify the above SQL statement to format the date into MySQL's

MySql bulk load command line tool

二次信任 提交于 2019-11-26 14:09:48
问题 Does MySql have a bulk load command line tool like bcp for SQLServer and sqlldr for Oracle? I know there's a SQL command LOAD INFILE or similar but I sometimes need to bulk load a file that is on a different box to the MySQL database. 回答1: mysqlimport. takes the same connection parameters as the mysql command line shell. Make sure to use the -L flag to use a file on the local file system, otherwise it will (strangely) assume the file is on the server. There is also an analogous variant to the

MySQL load data infile - acceleration?

不羁的心 提交于 2019-11-26 12:07:10
问题 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

Import CSV to mysql table

牧云@^-^@ 提交于 2019-11-26 09:54:51
What is the best/fastest way to upload a csv file into a mysql table? I would like for the first row of data be used as the column names. Found this: How to import CSV file to MySQL table But the only answer was to use a GUI and not shell? Instead of writing a script to pull in information from a CSV file, you can link MYSQL directly to it and upload the information using the following SQL syntax. To import an Excel file into MySQL, first export it as a CSV file. Remove the CSV headers from the generated CSV file along with empty data that Excel may have put at the end of the CSV file. You can

LOAD DATA LOCAL INFILE gives the error The used command is not allowed with this MySQL version

时光毁灭记忆、已成空白 提交于 2019-11-26 09:40:03
问题 I have a PHP script that calls MySQL\'s LOAD DATA INFILE to load data from CSV files. However, on production server, I ended up with the following error: Access denied for user ... (using password: yes) As a quick workaround, I changed the command to LOAD DATA LOCAL INFILE which worked. However, the same command failed on client\'s server with this message: The used command is not allowed with this MySQL version I assume this has something to do with the server variable: local_infile = off as

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

我只是一个虾纸丫 提交于 2019-11-26 07:22:28
问题 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 回答1: You could use SQL for this: $file = 'backups/mytable.sql'; $result = mysql_query("SELECT * INTO OUTFILE '$file' FROM `##table##`"); Then just

Import CSV to MySQL

自闭症网瘾萝莉.ら 提交于 2019-11-26 06:34:06
问题 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

PHP - Import CSV file to mysql database Using LOAD DATA INFILE

房东的猫 提交于 2019-11-26 05:30:00
问题 I have a .csv file data like that Date,Name,Call Type,Number,Duration,Address,PostalCode,City,State,Country,Latitude,Longitude \"Sep-18-2013 01:53:45 PM\",\"Unknown\",\"outgoing call\",\'123456\',\"0 Secs\",\"null\",\"null\",\"null\",\"null\",\"null\",0.0,0.0,,, \"Sep-18-2013 01:54:14 PM\",\"Unknown\",\"outgoing call\",\'1234567890\',\"0 Secs\",\"null\",\"null\",\"null\",\"null\",\"null\",0.0,0.0,,, \"Sep-18-2013 01:54:37 PM\",\"Unknown\",\"outgoing call\",\'14772580369\',\"1 Secs\",\"null\",