cocos 报错dts文件未导入_首次使用命令行Mysql导入csv数据

d74a6571fbe8b32b3097e5904ade01df.png

背景描述:

使用MySQL 8.0 Command Line Cline 命令行将CSV文件导入table中,win10系统。

方式:

1、找到mysql中欲导入数据的table

mysql> SHOW databases;
+--------------------+
| Database           |
+--------------------+
| data               |
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
| world              |
+--------------------+
7 rows in set (0.00 sec)

mysql>USE data;
Database changed

mysql> SHOW tables;
+----------------+
| Tables_in_data |
+----------------+
| company        |
| dataanalyst    |
| orderinfo      |
| userinfo       |
+----------------+
4 rows in set (0.00 sec)

2、找到secure_file_priv文件夹(因为这事安全文件夹,所以只有这个文件夹中的文件才能上传)

mysql> SHOW variables like '%secure%' ;
+--------------------------+------------------------------------------------+
| Variable_name            | Value                                          |
+--------------------------+------------------------------------------------+
| require_secure_transport | OFF                                            |
| secure_file_priv         | C:ProgramDataMySQLMySQL Server 8.0Uploads |
+--------------------------+------------------------------------------------+
2 rows in set, 1 warning (0.00 sec)

3、将csv文件放入secure_file_priv 所指向的文件夹

(以我为例,需要将csv文件放入C:ProgramDataMySQLMySQL Server 8.0Uploads中)

4、执行导入命令

mysql> load data infile 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/user_info_utf.csv'
    -> into table userinfo
    -> fields terminated by ',' ;
Query OK, 32079 rows affected (0.26 sec)
Records: 32079  Deleted: 0  Skipped: 0  Warnings: 0

5、成功。

补充说明:

在第4步中,对于MySQL 8.0的版本,会出现报错(报错原因比较有趣):

Incorrect integer value ” for column ‘name’ at row 1

报错原因:

In this situation, what is happening is that the script is attempting to insert or update a row with the integer entry taking on either the default value (e.g., of 0 or NULL) or the next AUTO_INCREMENTvalue.

But MySQL is not interpreting this action as valid due to its SQL_MODE being in STRICT mode.

解决方法:

In this case, to not treat this action as an error, edit my.ini, find this line –

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

And set to to an empty string –

sql_mode=""

Save my.ini, restart MySQL.

some other points.

  1. Where is your my.ini?

You should find where your sql install in.

2. How to restart MySQL?

这里有一种方法

参考资料:

windows下重启mysql的方法

解决Incorrect integer value: '' for column 'id' at row 1的方法

MySQL Error “Incorrect integer value ” for column ‘name’ at row 1″

微信公众号:

4d36eacf9dd4a21eebec4ff83060a4ff.png
公众号ID: AppleGossip

简书:https://www.jianshu.com/u/505e89457641

知乎:https://www.zhihu.com/people/zhao-yue-62-24/posts

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值