mysql导入sql文件时,因为编码问题,报错data too long for column

今天在把一个sql文件导入到数据库的时候因为中文编码报错了,下面是解决该问题的方法:

连接数据库时设置编码

mysql -u root -p --default-character-set=utf8

切换到需要导入的数据库

use dbname

使用source命令导入

 source db.sql

db.sql是你的sql文件绝对或相对路径

发布了29 篇原创文章 · 获赞 3 · 访问量 4674

猜你喜欢

转载自blog.csdn.net/weixin_44898301/article/details/105679233