grant all privileges on * . * to 'root'@'%' identfied by 'abc123';
修改数据库中用户的登陆密码
update mysql.user set authentication_string=password ('1234567') where user='tom';
创建数据库
create database school;
进入数据库,并设置属性
use school;
create table info (id int(3) not null primary key auto_increment,name varchar(10) not null,scroe decimal(5,2),address varchar(50) default '未知');
刷新
flush privileges;
刷新后,要重进数据库
向创建的数据库中添加数据
1) insert into info (id,name,score,address) values (1,'zhangsan',88.5,'nanjing');
2) insert into info values (3,'wangwu',77,'shanghai');
3) insert into info (name,score,address) values ('zhaoliu',99,'suzhou'),('tianqi',60,default);
将筛选的结果生成一个新的表
create table tmp as select * from where score > 80;
修改表内信息
update info set score=66 where name='zhaoliu' ;
删除表内的信息
delete from tmp where score >= 90; ///将tmp表内大于90分的删除
删除表内所有信息
delete from tmp;
清空所有数据
truncate table info;
删除表
drop table tmp;
删除创建的数据库
drop database school;
创建一个临时表
create temporary table temp_info (id int(4) not null auto_increment,name varchar(10) not null,hobby varchar(10) not null,primary key(id))engine=innodb default charset=utf8;
克隆表
create table tmp like info;
使用DCL语句设置用户权限(若用户不存在,则新建用户)
grant all on * .* to 'jerry'@'localhost' indentified by 'abc123'
数据库提权
grant all privileges on *.* to 'root'@'%' identified by '123456';
允许使用root用户从任意终端进行访问所有数据库中的所有表