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

    转自:http://www.cnblogs.com/dadadechengzi/p/6034212.html

    查看mysql数据编码

    登录MySQL服务,查看mysql数据库默认的编码

    mysql> show variables like 'character%';
    +--------------------------+-------------------------------------------------+
    | Variable_name            | Value                                           |
    +--------------------------+-------------------------------------------------+
    | character_set_client     | gbk                                             |
    | character_set_connection | gbk                                             |
    | character_set_database   | latin1                                          |
    | character_set_filesystem | binary                                          |
    | character_set_results    | gbk                                             |
    | character_set_server     | latin1                                          |
    | character_set_system     | utf8                                            |
    | character_sets_dir       | E:Developmysql-5.7.15-winx64sharecharsets |
    +--------------------------+-------------------------------------------------+
    8 rows in set, 1 warning (0.00 sec)
    
    mysql>

    可以看出database和server都采用了latin1编码,不支持中文,我们需要把它修改为utf-8。

    除了这两个,其它的如下

    | 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       | E:0Developmysql-5.7.15-winx64sharecharsets 

    设置mysql数据库编码

    在mysql安装目录下,将 my-default.ini 复制一分保存为 my.ini 
    做如下修改 
    陈科肇

    主要看红色框里的内容

    [mysqld]
    character-set-server=utf8 
    collation-server=utf8_general_ci 
    
    [mysql]
    default-character-set = utf8
    
    [mysql.server]
    default-character-set = utf8
    
    
    [mysqld_safe]
    default-character-set = utf8
    
    
    [client]
    default-character-set = utf8
    

    然后删除你当前的mysql服务,再重新注册mysql服务 
    注:一定要以管理员的权限运行dos命令,且cd到mysql安装目录下的bin目录,再注册mysql服务

    C:Windowssystem32>sc delete mysql
    [SC] DeleteService 成功
    
    C:Windowssystem32>e: cd
    E:>cd E:Developmysql-5.7.15-winx64in
    
    E:Developmysql-5.7.15-winx64in>mysqld --install mysql --defaults-file="E:Developmysql-5.7.15-winx64my.ini"
    The service already exists!
    The current server installed: E:Developmysql-5.7.15-winx64inmysqld MySQL
    
    E:Developmysql-5.7.15-winx64in>net stop mysql
    MySQL 服务正在停止..服务名无效。
    请键入 NET HELPMSG 2185 以获得更多的帮助。
    
    E:Developmysql-5.7.15-winx64in>mysqld --install mysql --defaults-file="E:Developmysql-5.7.15-winx64my.ini"
    Service successfully installed.
    E:Developmysql-5.7.15-winx64in>

    结果

    启动服务,查看编码

    C:WindowsSystem32>net start mysql
    mysql 服务正在启动 .
    mysql 服务已经启动成功。
    
    
    C:WindowsSystem32>mysql -u root
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.15 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2016, 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       | E:Developmysql-5.7.15-winx64sharecharsets |
    +--------------------------+-------------------------------------------------+
    8 rows in set, 1 warning (0.00 sec)
    
    mysql>
  • 相关阅读:
    字典或者数组与JSON串之间的转换
    银联支付 支付代码
    iOS 一个新方法:- (void)makeObjectsPerformSelector:(SEL)aSelector;
    iOS 直接使用16进制颜色
    iOS 添加view的分类(更加方便的设置view的位置)
    iOS 中UITableView的深理解
    Swift 中调试状态下打印日志
    手把手教React Native实战开发视频教程【更新到40集啦。。。】
    React Native 开发
    React-Native学习指南
  • 原文地址:https://www.cnblogs.com/ow0843/p/9829557.html
Copyright © 2011-2022 走看看