###仅作个人用
说白了就是要统一字符集, 客户端and服务端,数据库,表,程序编码 推荐用utf8 先查看数据库编码或者表的编码
show create database (db_name) \G;show create table (table_name) \G;
####1.set names latin1 (反正要设置成和数据库编码或者表的编码一致,latin1仅作示例)
set names latin1;
然后就可以愉快插入数据了,但只是临时生效,退出了就无效。
####2.连接mysql的时候指定字符集
mysql -uroot -p12345678 --default-character-set=latin1
####3.修改my.cnf配置达到编码一致
vim /etc/my.cnf
找到[client]加入
--default-character-set=latin1
找到[mysqld]加入
--default-character-set=latin1
ZZ or wq!保存退出