SQL语言
- DDL数据定义语言: create drop alter
- DML数据操作语言: insert into, delete,update,select
- DCL数据控制语言: grant,revoke
创建库
show databases;
create database test_data;
use test_data;
select database();
show tables;
drop database test_data;
创建表
create table stu (id int unsigned not null primary key,name varchar(10) not null,age tinyint unsigned);
select * from stu;
drop table stu;
alter table stu modify age tinyint unsigned not null;
insert into stu values (1,'zhangshan',16),(2,'lili',19);
select * from stu where id>1;
select * from stu order by id;
select * from stu order by id desc;
delete from stu where id=2;
update stu set name='liyi' where id=2;
#update user set password=password('zabbix') where user='zabbix';
update user set authentication_string=password('zabbix') where user='zabbix'; #mysql5.7
创建用户
create user 'test'@'192.168.1.%';
set password for test@'192.168.1.%'=password('456789'); #设置和修改密码
create user 'test'@'192.168.1.%' identified by '123456';
drop user 'test'@'192.168.1.%';
授权
create user 'test'@'192.168.1.%' identified by '123456';
grant all on *.* to 'test'@'192.168.1.%'; 授权用户
show grants for 'test'@'192.168.1.%'; # 查看授权信息
revoke all on test.* from test@'192.168.1.%'; # 回收授权
相关文章
暂无评论...