zoukankan      html  css  js  c++  java
  • Ubuntu下MySql中文最终解决方法

    一,登陆mysql用status查看数据库的基本信息

    mysql> status
    --------------
    mysql  Ver 14.14 Distrib 5.5.46, for debian-linux-gnu (x86_64) using readline 6.3
    
    Connection id:		36
    Current database:	rinpsi
    Current user:		root@localhost
    SSL:			Not in use
    Current pager:		less
    Using outfile:		''
    Using delimiter:	;
    Server version:		5.5.46-0ubuntu0.14.04.2 (Ubuntu)
    Protocol version:	10
    Connection:		Localhost via UNIX socket
    Server characterset:	latin1
    Db     characterset:	latin1
    Client characterset:	utf8
    Conn.  characterset:	utf8
    UNIX socket:		/var/run/mysqld/mysqld.sock
    Uptime:			2 min 42 sec
    
    Threads: 1  Questions: 128  Slow queries: 0  Opens: 49  Flush tables: 1  Open tables: 41  Queries per second avg: 0.790
    --------------
    

    可以看到服务器和数据库的字符编码都是latin1,我们的目标是把他们设置成uf8


    二,具体步骤就是修改/etc/mysql/my.conf文件中的字符集键值

    1.[client]字段

    [client]
    port            = 3306
    socket          = /var/run/mysqld/mysqld.sock
    ##添加
    default-character-set=utf8
    ##添加
    
    2.[mysqld]字段

    [mysqld]
    #
    # * Basic Settings
    #
    ##添加
    character-set-server=utf8
    ##添加
    
    3.[mysql]字段

    [mysql]
    #no-auto-rehash # faster start of mysql but no tab completition
    ##添加
    default-character-set=utf8
    

    三,重启mysql,再次登陆验证修改

    service mysql restart
    
    


    mysql> status
    --------------
    mysql  Ver 14.14 Distrib 5.5.46, for debian-linux-gnu (x86_64) using readline 6.3
    
    Connection id:		36
    Current database:	rinpsi
    Current user:		root@localhost
    SSL:			Not in use
    Current pager:		less
    Using outfile:		''
    Using delimiter:	;
    Server version:		5.5.46-0ubuntu0.14.04.2 (Ubuntu)
    Protocol version:	10
    Connection:		Localhost via UNIX socket
    Server characterset:	utf8
    Db     characterset:	utf8
    Client characterset:	utf8
    Conn.  characterset:	utf8
    UNIX socket:		/var/run/mysqld/mysqld.sock
    Uptime:			2 min 42 sec
    
    Threads: 1  Questions: 128  Slow queries: 0  Opens: 49  Flush tables: 1  Open tables: 41  Queries per second avg: 0.790
    --------------
    





  • 相关阅读:
    CXF调用webservice超时设置
    CSRF攻击测试及防御
    RMS去除在线认证
    Tuning 05 Sizing other SGA Structure
    Tuning 04 Sizing the Buffer Cache
    Oracle Tuning ( instance 级别 ) 01
    oracle tuning 工具
    Oracle Tuning 总括
    Transporting Data Between Database
    RMAN Restore, Recovery
  • 原文地址:https://www.cnblogs.com/A-yes/p/9894210.html
Copyright © 2011-2022 走看看