mysql> alter database mydb character set utf8 ; 2、创建数据库时,指定数据库的字符编码
mysql> create database mydb character set utf8 ; 3、查看mysql数据库的字符编码
mysql> show variables like 'character%'; //查询当前mysql数据库的所有属性的字符编码
+--------------------------+----------------------------+ | 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 | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 4、修改mysql数据库的字符编码
mysql> set character_set_client=utf8 ;
mysql> set character_set_connection=utf8 ; mysql> set character_set_database=utf8 ; mysql> set character_set_database=utf8 ; mysql> set character_set_results=utf8 ; mysql> set character_set_server=utf8 ; mysql> set character_set_system=utf8 ; mysql> show variables like 'character%';
+--------------------------+----------------------------+ | 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 | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)
因篇幅问题不能全部显示,请点此查看更多更全内容