zoukankan      html  css  js  c++  java
  • CentOS修改Mysql字符集

    1、mysql>show variables like 'character_set%';

    显示如下:

    +--------------------------+----------------------------+  
    | Variable_name            | Value                      |  
    +--------------------------+----------------------------+  
    | character_set_client     | latin1                     |  
    | character_set_connection | latin1                     |  
    | character_set_database   | latin1                     |  
    | character_set_filesystem | binary                     |  
    | character_set_results    | latin1                     |  
    | character_set_server     | latin1                     |  
    | character_set_system     | utf8                       |  
    | character_sets_dir       | /usr/share/mysql/charsets/ |  
    +--------------------------+----------------------------+ 

    2、备份my.cnf   cp /etc/my.cnf /etc/my.cnf.bak

    3、修改my.cnf,结果如下

    [client]  
    port=3306  
    socket=/var/lib/mysql/mysql.sock  
    default-character-set=utf8  
     
    [mysqld]  
    datadir=/var/lib/mysql  
    socket=/var/lib/mysql/mysql.sock  
    user=mysql  
    # Disabling symbolic-links is recommended to prevent assorted security risks  
    symbolic-links=0  
    character-set-server=utf8  
     
    [mysql]  
    no-auto-rehash  
    default-character-set=utf8  
     
    [mysqld_safe]  
    log-error=/var/log/mysqld.log  
    pid-file=/var/run/mysqld/mysqld.pid 

    4、重启mysql服务 sudo service mysqld restart

    5、mysql>show variables like 'character_set%';

    进入mysql控制台后,执行以下命令

    修改默认字符集
     1.1修改服务器默认字符集
     set character_set_server=utf8
     1.2修改数据库字符集
     set character_set_database=utf8;
     1.3修改数据库客户端字符集
     set character_set_client=utf8;
     1.4修改连接默认字符集
     set character_set_connection=utf8

    修改已经存在库的字符集 2.1修改存在数据库的字符集 alter database mydb character set utf8; 2.2修改存在表的字符集 alter table mytable default character set utf8

    结果如下:

    +--------------------------+----------------------------+  
    | 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/ |  
    +--------------------------+----------------------------+  

    6、其他一些常用命令

    设置密码
    use mysql;
    update user set password=password('密码') where user='root';
    flush privileges;
    授权
    grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
  • 相关阅读:
    VS 格式化代码 Ctrl + K, Ctrl + F
    VS NuGet使用
    VS书签的应用
    ASP.Net简单的交互案例
    英文书也没有那么难,跟着例子做,挺有意思的
    .Net强类型视图
    .Net视图机制
    .Net MVC小尝试
    ASP.Net MVC默认目录结构
    .Net中常用的几种ActionResult
  • 原文地址:https://www.cnblogs.com/ScvQ/p/6871714.html
Copyright © 2011-2022 走看看