https://zhuanlan.zhihu.com/p/555596861
例:
mysql> create database company;
例:
mysql> create table if not exists company.customers (
-> id int unsigned auto_increment primary key,
-> first_name varchar(20),
-> last_name varchar(20),
-> country varchar(20)
-> ) engine=InnoDB;
mysql> select emp_no,dept_no from dept_manager;
mysql> select * from departments;
mysql> select count(*) from employees;
SELECT distinct deptno_id from emp; #在select 语句中使用distinct 筛选重复
mysql> select count(*) from employees where first_name like 'Christ%';
mysql> select count(*) from employees where first_name like 'Christ%ed';
mysql> insert into company.customers (first_name,
-> last_name,country)
-> values
-> ('mike','christensen','USA'),
-> ('andy','Hollands','Australia'),
-> ('ravi','vedantam','India'),
-> ('rajiv','perera','Sri lanka');
mysql> update customers set first_name='rajiv',country='UK' where id=4;
#where字句是强制性的。如果没有给出它,update会更新整个表。
mysql> delete from customers where id=4 and first_name='rajiv';
#where字句是强制性的。如果没有给出它,delete将删除表中的所有行。
#授权
grant select ,insert,update on db1.t1 to "ycw"@'%';
#撤销ycw用户对数据库db1的所有表的所有权限
revoke all on db1.* from 'ycw'@"%";
#撤销ycw用户所有数据库的所有的表的权限
revoke all privileges on '*' from 'ycw'@'%';