MySQL 基础语句

# mysql 创建表
create table user(
id int unsigned not null auto_increment primary key comment '注释',
username varchar(20) not null comment '注释',
password char(32) not null comment '注释');

# 显示编码
show variables like '%char%';
set names gbk;

# 显示创建表SQL
show create table user;

# 清空表数据
truncate user; 

# 刷新权限
flush privileges;

# 跳过权限(用于配置文件中)
mysqld --skip-grant-tables

# 创建数据库
CREATE DATABASE test2 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

# 创建用户
grant all on test.* to test@'%' identified by 'password';

# 撤销权限
revoke all on test.* from test@'%';