我想将大型 xlsx(电子表格文件)导入到MySQL数据库中。 我以前通过phpmyadmin完成了此操作,但是这个文件太大了(205000行)。
所以当我尝试使用phpmyadmin时,它花费了很长时间并且无法完成。
有什么最好且快速的方法可以将其导入到MySQL数据库中吗?
我想将大型 xlsx(电子表格文件)导入到MySQL数据库中。 我以前通过phpmyadmin完成了此操作,但是这个文件太大了(205000行)。
所以当我尝试使用phpmyadmin时,它花费了很长时间并且无法完成。
有什么最好且快速的方法可以将其导入到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!
Toad for MySQL(免费软件)将是另一个选择。