@@ -15,11 +15,11 @@ show variables like 'collation%';
1515vim /etc/mysql/my.cnf
1616
1717[client]
18- default-character-set=utf8mb4_bin 
18+ default-character-set=utf8mb4 
1919
2020[mysqld]
2121default-storage-engine=INNODB
22- character-set-server=utf8mb4_bin 
22+ character-set-server=utf8mb4 
2323collation-server=utf8mb4_bin
2424
2525/etc/init.d/mysql stop
@@ -28,42 +28,50 @@ collation-server=utf8mb4_bin
2828
2929``` mysql 
3030--  服务端
31- set  global character_set_server= utf8mb4_bin ;
32- set  global character_set_database= utf8mb4_bin ;
31+ set  global character_set_server  =  utf8mb4 ;
32+ set  global character_set_database  =  utf8mb4 ;
3333
3434--  客户端
35- set  global character_set_client= utf8mb4_bin ;
36- set  global character_set_connection= utf8mb4_bin ;
37- set  global character_set_results= utf8mb4_bin ;
35+ set  global character_set_client  =  utf8mb4 ;
36+ set  global character_set_connection  =  utf8mb4 ;
37+ set  global character_set_results  =  utf8mb4 ;
3838
39- create  database  if  not exists ` db1` /* !40100 default character set utf8mb4_bin  */ 
39+ create  database  if  not exists ` db1` /* !40100 default character set utf8mb4  */ 
4040
41- --  drop table if exists `db1_table1`;
42- create  table  if  not exists db1_table1
41+ --  show create table db1_table0;
42+ drop  table  if exists ` db1_table0` 
43+ create  table  if  not exists db1_table0
4344(
44-   id          bigint  unsigned auto_increment comment ' 自增主键' 
45-   create_time datetime  not null                comment ' 创建时间' 
46-   update_time datetime  null                    comment ' 更新时间' 
47-   constraint  db1_table1_pk primary key  (id),
48-   constraint  db1_table1_id_unique_index unique (id)
45+      id          bigint ( 20 )  unsigned  not null  auto_increment comment ' 自增主键' 
46+      create_time datetime( 6 )          not null  default  current_timestamp ( 6 )  comment ' 创建时间' 
47+      update_time datetime( 6 )          not null  default  current_timestamp ( 6 )  on   update   current_timestamp ( 6 )  comment ' 更新时间' 
48+      constraint  db1_table1_pk primary key  (id),
49+      constraint  db1_table1_id_unique_index unique (id)
4950) engine =  InnoDB
50-   default charset =  utf8mb4_bin comment = ' 表名' 
51+   default charset =  utf8mb4
52+   collate =  utf8mb4_bin comment = ' 表名' 
5153
52- --  主键用id
54+ --  show create table db1_table1;
55+ drop  table  if exists ` db1_table1` 
5356create  table  if  not exists db1_table1
5457(
55-   id          bigint  unsigned auto_increment primary key  unique comment ' 自增主键' 
56-   create_time datetime not null  comment ' 创建时间' 
57-   update_time datetime null  comment ' 更新时间' 
58- ) ENGINE =  InnoDB
59-   DEFAULT CHARSET =  utf8mb4_bin COMMENT = ' 表名' 
58+     id          bigint (20 ) unsigned not null  auto_increment primary key  unique comment ' 自增主键' 
59+     create_time datetime(6 )         not null  default current_timestamp (6 ) comment ' 创建时间' 
60+     update_time datetime(6 )         not null  default current_timestamp (6 ) on  update  current_timestamp (6 ) comment ' 更新时间' 
61+ ) engine =  InnoDB
62+   default charset =  utf8mb4
63+   collate =  utf8mb4_bin comment = ' 表名' 
6064
61- --  show create table db1_table1;
62- CREATE  TABLE  `db1_table1 ` (
63-   ` id` bigint (20 ) unsigned NOT NULL  AUTO_INCREMENT COMMENT ' 自增主键' 
64-   ` create_time` NOT NULL  COMMENT ' 创建时间' 
65-   ` update_time` NULL  COMMENT ' 更新时间' 
66-   PRIMARY KEY  (` id` 
67-   UNIQUE KEY ` id` ` id` 
68- ) ENGINE= InnoDB DEFAULT CHARSET= utf8mb4_bin COMMENT= ' 表名' 
65+ --  show create table db1_table2;
66+ drop  table  if exists ` db1_table2` 
67+ create  table  if  not exists ` db1_table2` 
68+ (
69+     ` id` bigint (20 ) unsigned not null  auto_increment comment ' 自增序号' 
70+     ` create_time` 6 )         not null  default current_timestamp (6 ) comment ' 创建时间' 
71+     ` update_time` 6 )         not null  default current_timestamp (6 ) on  update  current_timestamp (6 ) comment ' 更新时间' 
72+     primary key  (` id` 
73+     unique key ` id` ` id` 
74+ ) engine =  InnoDB
75+   default charset =  utf8mb4
76+   collate =  utf8mb4_bin comment = ' 表名' 
6977``` 
0 commit comments