MySQL 命令行下 字符集设置
在命令行工具mysql下,操作数据库时要保证编码的一致。
这里所说的编码是指数据库编码,连接编码,客户端编码。
可以通过命令 show variables like 'character_set_%';来查询
|
|
|
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | C:\mysql-5.0.51b-win32\share\charsets\ |
+--------------------------+----------------------------------------+
8 rows in set (0.00 sec)
|
Latin1是瑞典编码,
如果要更改编码,使用下面的命令:set character_set_client=utf8;
mysql> set character_set_client=utf8; Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_connection=utf8; Query OK, 0 rows affected (0.00 sec) |
只要你的三个编码
character_set_client character_set_connectio character_set_database
保持一致,在命令行工具下,操作就不会出现乱码问题。
阅读(5314) | 评论(2) | 转发(0) |