今天心情不好...
同事让帮忙导数据表,我直接命令行连接后 使用source导入,
但是导入的中文数据出现乱码情况;
百度了一下问题
定位是编码问题, 查看编码:mysql> show variables like 'char%';
+--------------------------+--------+
| Variable_name | Value |
+--------------------------+--------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | |
+--------------------------+--------+
8 rows in set (0.00 sec)
在简练连接时就设置默认编码 为 utf-8 编码统一mysql -h 127.0.0.1 -u root -p --default-character-set=utf8
查看编码:mysql> show variables like '%char%';
+--------------------------+--------+
| Variable_name | Value |
+--------------------------+--------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | |
+--------------------------+--------+
8 rows in set (0.00 sec)
再倒入sqlmysql> source /home/tb.sql
Query OK, 0 rows affected (0.00 sec)
ok 问题解决