• 2-MySQL数据库编码uft-8


    mysql> show variables like 'character%';

    mysql> show variables like 'collation%';

    mysql> status;

    mysql> exit;

    vim /etc/my.cnf

    [mysqld]
    default-storage-engine=INNODB
    character-set-server=utf8
    collation-server=utf8_general_ci

    init_connect='SET NAMES utf8'

    [mysql]
    default-character-set=utf8

    [mysql.server]
    default-character-set=utf8

    [mysqld_safe]
    default-character-set=utf8

    [client]
    default-character-set=utf8

    :wq!

    systemctl restart mysqld

    mysql> show create database 数据库名;
    mysql> show create table 表名;

    设置默认编码为utf8:
    set names utf8;

    设置数据库db_name默认为utf8:
    ALTER DATABASE `db_name` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    设置表tb_name默认编码为utf8:
    ALTER TABLE `tb_name` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

    创建数据库的时候:

    CREATE DATABASE `test`
    CHARACTER SET 'utf8'
    COLLATE 'utf8_general_ci';

    建表的时候:

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

    创建数据库

    create table cantus(
    id int(10) not null auto_increment primary key,
    song char(20) not null,
    album char(20) not null,
    number smallint(5) not null,
    writer char(12) not null,
    composer char(12) not null,
    singing char(12) not null,
    lyric varchar(2000) not null);

    create table orders(
    id int(10) not null auto_increment primary key,
    song char(20) not null,
    album char(20) not null,
    num smallint(5) not null,
    number smallint(5) not null)ENGINE=InnoDB DEFAULT CHARSET=utf8;

  • 相关阅读:
    bzoj 5092: [Lydsy1711月赛]分割序列
    bzoj1173: [Balkan2007]Point
    bzoj1536: [POI2005]Akc- Special Forces Manoeuvres
    bzoj2178: 圆的面积并
    bzoj1043 下落的圆盘
    bzoj2674 Attack
    bzoj1201: [HNOI2005]数三角形
    bzoj3135: [Baltic2013]pipesd
    bzoj1760 [Baltic2009]Triangulation
    bzoj3136
  • 原文地址:https://www.cnblogs.com/ninghongkun/p/5807898.html
Copyright © 2020-2023  润新知