| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
查看指定的数据库中指定数据表的字符集,如查看 mysql 数据库中 servers 表的字符集:
show table status from mysql like \'%servers%\';
查看指定数据库中指定表的全部列的字符集,如查看 mysql 数据库中 servers 表的全部的列的字符集:
show full columns from servers;
19 设置 MySQL 的字符集为 UTF-8:
打开 /etc 目录下的 my.cnf 文件(此文件是 MySQL 的主配置文件):
/etc/my.cnf
在 [mysqld] 前添加如下代码:
[client]
default-character-set=utf8
在 [mysqld] 后添加如下代码:
character_set_server=utf8
再次查看字符集:
mysql> show variables like \'%character%\';
+--------------------------+----------------------------+