2.右键选中新建的表,点击导入向导
3.在d出的选项框中选择CSV文件格式,点击下一步。
6.选择CSV文件中数据的字段名行和数据的开始行,点击下一步(注意这里一定要选择正确不然会导致导入数据出错)
CSV 格式导入到MYSQL中。执行语句:
load data infile '你的CSV文件路径' into table 你的表 fields terminated by ',' lines terminated by '\n'
实例:
库:pc2phone表:cms_rate文件路径:C:/A-Z.csv
一:Xls转化(另存)为 .csv格式(A-Z.csv)。存放到C盘根目录下
二:MySQL Command Line Client执行 *** 作。
1: mysql>use pc2phone
Database Changed
2: mysql>load data infile 'C:/A-Z.csv' into table cms_rate fields terminated by ',' lines terminated by '\n'
如果编码正确,导入成功!
如果出现下边情况,则说明编码格式错误。需要对C:/A-Z.csv文件的编码进行转换。
ERROR 1366 <hy000>:Incorrect string value: '\xB9\xFA\xBC\xCA\xB3\xA4...' for column 'rate_type' at row 1
mysql>create table test(x int) engine=csv//ERROR 1178 (42000): The storage engine for the table doesn't support nullable columns
mysql>create table test(x int not null) engine=csv//
Query OK, 0 rows affected (0.05 sec)
mysql>create table test(x int) engine=archive//
这样?
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)