• Mysql中文乱码 小强斋


    一、Mysql乱码解决办法

    (1)修改 my.ini(MySQLServer Instance Configuration文件)为gbk

    [client]
    
    port=3306
    
    [mysql]
    
    default-character-set=gbk
    
    
    # SERVER SECTION
    # ----------------------------------------------------------------------
    #
    # The following options will be read by the MySQL Server. Make sure that
    # you have installed the server correctly (see above) so it reads this 
    # file.
    #
    [mysqld]
    
    # The TCP/IP Port the MySQL Server will listen on
    port=3306
    
    
    #Path to installation directory. All paths are usually resolved relative to this.
    basedir="C:/Program Files/MySQL/MySQL Server 5.1/"
    
    #Path to the database root
    datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data/"
    
    # The default character set that will be used when a new schema or table is
    # created and no character set is defined
    default-character-set=gbk

    (2)修改data目录中相应数据库目录下的db.opt配置文件(C:\ProgramData\MySQL\MySQL Server 5.1\data)

    default-character-set=gbk
    default-collation=gbk_chinese_ci

    (3)在创建数据库时指定字符集
    create database yourDB  CHARACTER  SET gbk;

    (4)建表的时候

    CREATE TABLE `user` (
     `ID` varchar(40) NOT NULL default '',
     `UserID` varchar(40) NOT NULL default '',
     ) ENGINE=InnoDB DEFAULT CHARSET=gbk;

    二、常用命令:
    1.查看默认的编码格式:
    mysql> show variables like "%char%";

     2.查看test数据库的编码格式:
    mysql> show create database test;

    3.查看test表的编码格式:
    mysql> show create table test;

  • 相关阅读:
    sysbench压测Oracle
    linux使用FIO测试磁盘的iops
    oracle 列授权相关测试
    11G、12C安装结束需要做的一些操作
    Oracle 12C R2 on Linux 7.X 单实例静默安装文档
    auto_create_partition
    关于使用索引的一些经验
    转:【Python3网络爬虫开发实战】 requests基本用法
    转:http协议学习系列(响应头---Response Headers)
    关于建立老猿Python研学群的公告
  • 原文地址:https://www.cnblogs.com/xiaoqiangzhaitai/p/5429440.html
Copyright © 2020-2023  润新知