最近课程实验,又和mysql (mariadb) 杠上了,觉得只要扯到mysql,乱码都是永远的痛。
CentOS下的默认编码是UTF-8,所以把数据库的默认编码也设置为UTF-8
alter database test default character set utf8;
mysql 执行外部的 sql 脚本使用 source 命令
source /home/hzr/create.sql;
mysql 导入外部文本数据时的方法是:
load data local infile '/home/hzr/student.txt' into table student fields terminated by '\t';