数据库—数据库管理
创建数据库(create-user和grant):
create-user的使用方法:
create user 'w1'@'localhost' identified by '123456';
grant的使用方法:
grant all on *.* to 'w2;@'%' identified by '123456';
# with grant option(将自己的权限赋予指定数据库)
grant all on *.* to 'w3'@'%' identified by '123456' with grant option;
查询所建数据库的权限:
show grants for 'w3'@'%';
查询所创建的数据库:
select host,user,select_pri,update_pri from mysql.user where host='localhost' and user='w1';
向user表中插入数据:
insert into mysql.user(Host,User,Password,ssl_cipher,x509_issuer,x509_subject) values
('localhost','w3',password('123456'),'s','s','s');
删除数据库:
方式1:
drop user 'w1'@'localhost';
方式2:
delect from mysql.user where host='localhost' and user='w1';
修改密码(set和update):
set方法:
set password=password('123123');
set修改指定数据库的密码:
set password for 'w2'@'%' =password('123456');
update方法:
update mysql.user set authentified_string=password('123123') where host='localhost' and user='w1';