zoukankan      html  css  js  c++  java
  • MySQL 字符集设置

    /***************************************************************************
     *                         MySQL 字符集设置
     * 说明:
     *     数据库这块很多时候都会因为字符集不兼容导致数据通信异常,所以这边把
     * MySQL的字符集设定为utf-8,这个比较通用。
     *
     *                                         2016-9-24 深圳 南山平山村 曾剑锋
     **************************************************************************/
    
    一、参考文档:
        1. (原创)Linux下MySQL 5.5/5.6的修改字符集编码为UTF8(彻底解决中文乱码问题)
            http://www.ha97.com/5359.html
    
    二、解决办法:
        cat /etc/my.cnf
            ......
            [client]
            ......
            default-character-set=utf8
            ......
            [mysql]
            ......
            default-character-set=utf8
            ......
            [mysqld]
            ......
            collation-server = utf8_unicode_ci
            init-connect='SET NAMES utf8'
            character-set-server = utf8
            ......
    
    三、查看结果:
        [aplex@root ~]# mysql -u root -p
        Enter password: 
        Welcome to the MySQL monitor.  Commands end with ; or g.
        Your MySQL connection id is 1
        Server version: 5.1.73-log Source distribution
        
        Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
        
        Oracle is a registered trademark of Oracle Corporation and/or its
        affiliates. Other names may be trademarks of their respective
        owners.
        
        Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
        
        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)
        
        mysql> quit
        Bye
        [aplex@root ~]# 
  • 相关阅读:
    搭建企业级Docker Registry -- Harbor
    搭建私服-docker registry
    CentOS 7.2修改网卡名称
    tomcat错误日志监控脚本
    Openresty+Lua+Redis灰度发布
    Jenkins权限控制-Role Strategy Plugin插件使用
    Rsyslog日志服务搭建
    awk4.0对数组value排序
    Spring-IOC 在非 web 环境下优雅关闭容器
    Spring-IOC bean 生命周期之 Lifecycle 钩子
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/5902542.html
Copyright © 2011-2022 走看看