修改mysql数据库编码为utf8,支持中文

    1)临时修改character_set_server的编码

    mysql> character_set_server=‘utf8’;

    2)永久性生效

    修改mysql服务的配置文件/etc/my.cnf

    [root@115 ~]# vim /etc/my.cnf

    …….

    [mysqld]

    ……

    **character_set_server = utf8 ** 【添加这一行内容】
    因为我的是ubuntu apt-get 安装的mysql 所以修改配置文件目录在 vi ./etc/mysql/mysql.conf.d/mysqld.cnf

    然后重启mysql服务
    已经修改了mysql的编码,保证各个编码参数均为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/local/mysql/share/charsets/ |
    +————————–+———————————-+
    8 rows in set (0.00 sec)