我想将大 xlsx (电子表格文件)导入mysql数据库。 我之前通过phpmyadmin做过,但这个文件太大了(205000行)。
因此,当我想通过phpmyadmin进行操作时,它花了很长时间才完成。
将它导入mysql数据库的最佳和快捷方式是什么?
答案 0 :(得分:6)
您可以使用MySQL中的LOAD DATA
命令来执行此操作:
http://blog.tjitjing.com/index.php/2008/02/import-excel-data-into-mysql-in-5-easy.html
Save your Excel data as a csv file (In Excel 2007 using Save As) Check the saved file using a text editor such as Notepad to see what it actually looks like, i.e. what delimiter was used etc. Start the MySQL Command Prompt (I usually do this from the MySQL Query Browser – Tools – MySQL Command Line Client to avoid having to enter username and password etc.) Enter this command: LOAD DATA LOCAL INFILE ‘C:\\temp\\yourfile.csv’ INTO TABLE database.table FIELDS TERMINATED BY ‘;’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\r\n’ (field1, field2); [Edit: Make sure to check your single quotes (') and double quotes (") if you copy and paste this code] Done!
答案 1 :(得分:0)
您可以尝试使用Navicat MySQL。我用250MB + xlsx文件完成了这项工作,Navicat完美无缺地处理它。
通过将max_allowed_packet
中的my.ini
选项更改为更大的数量(例如128M),确保将MySQL配置为能够接收大量数据。
答案 2 :(得分:0)
Toad for MySQL(免费软件)将是另一种选择。