今天在把一个sql文件导入到数据库的时候因为中文编码报错了,下面是解决该问题的方法:
- 连接数据库时设置编码
mysql -u root -p --default-character-set=utf8
- 切换到需要导入的数据库
use dbname
- 使用source命令导入
source db.sql
db.sql时.sql文件所在路径
今天在把一个sql文件导入到数据库的时候因为中文编码报错了,下面是解决该问题的方法:
mysql -u root -p --default-character-set=utf8
use dbname
source db.sql
db.sql时.sql文件所在路径