开发者

How do I upload very large files to MySQL without crashing my server?

开发者 https://www.devze.com 2023-02-17 14:46 出处:网络
I have several 50+ MB sized csv files I need to import to my MySQL server. I tried import开发者_开发技巧ing one using PhpMyAdmin, and the Apache server crashed. I\'ve tried a couple of windows tools,

I have several 50+ MB sized csv files I need to import to my MySQL server. I tried import开发者_开发技巧ing one using PhpMyAdmin, and the Apache server crashed. I've tried a couple of windows tools, like MySQL workbench, but found no options for importing csv.

I'm at a loss. What can I do?


Your files are CSV, right? Have you tried importing them directly into the MySQL server? I don't know how the other tools that you've tried do this, but MySQL has a command for importing from text files:

LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name
  FIELDS TERMINATED BY ',' ENCLOSED BY '"'
  LINES TERMINATED BY '\r\n'
  IGNORE 1 LINES;

Check this section of the reference manual.


You need to either use the LOAD DATA INFILE or mysqlimport command. They are the bulk upload tools for MySQL and should be able to handle your file without any problems. You can also turn indexing off before running the command then put it back on afterwards to improve performance a bit.


FTP or SSH the files onto your server.

Then use LOAD DATA INFILE to load the files into your database.

0

精彩评论

暂无评论...
验证码 换一张
取 消