zoukankan      html  css  js  c++  java
  • 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:MySQLMySQL Server 5.6sharecharsets |
    +--------------------------+-------------------------------------------+

    查看当前支持的字符集:

    show charset;

    查看数据库/表创建时的sql语句:

    show create database 库名G
    show create table 表名G

    查看表的信息:

    show table status from 库名 like  '表名';

    查看表中字段的信息:

    show full columns from 表名;

    设置字符集

    创建时指定字符:

    create database 库名 default character set=utf8; -- 建库时指定
    create table 表名(字段) default character set=utf8; -- 建表时指定

    修改全局字符集:

    set character_set_connection=utf8; -- 建立连接使用的编码
    set character_set_database=utf8; -- 数据库的编码
    set character_set_results=utf8; -- 结果集的编码
    set character_set_server=utf8; -- 数据库服务器的编码
    set character_set_system=utf8;
    set collation_connection=utf8;
    set collation_database=utf8;
    set collation_server=utf8;

    修改库的字符集:

    alter database 库名 default character set=字符集;

    修改表的字符集:

    alter table 表名 convert to character set 字符集;

    修改字段的字符集:

    alter table 表名 modify 字段名 约束条件 character set gbk/utf8;
  • 相关阅读:
    禁止用户选中页面
    冒泡排序
    hadoop-1.2.1安装配置
    CentOS碰到两个问题,顺便解决了下
    CentOS 安装
    VM配置一个待安装LUNIX系统的环境
    CentOS下IP的配置
    C++ Win系统下的调试
    题解 P1781 【宇宙总统】
    题解 P2089 【烤鸡】
  • 原文地址:https://www.cnblogs.com/dong-/p/10494669.html
Copyright © 2011-2022 走看看