1.登陸mysqlmysql
#mysql -u root -psql
2.新增用戶數據庫
insert into mysql.user(Host,User,Password) values("localhost","xxx",password("***"));ide
註釋:xxx爲新建用戶名,***爲用戶密碼it
3.執行該句後,還須要刷新權限表class
flush privileges;test
4.新建數據庫並賦予用戶權限
create database dbtest;登錄
所有受權:
容許本地登陸
grant all privileges on dbtest.* to xxx@localhost identified by "*";
容許任何主機登陸
grant all privileges on dbtest. to xxx@'%' identified by "";
部分受權:
grant select,update on dbtest.* to xxx@localhost identified by "***";date
5.賦予權限,還須要再刷新權限表select
flush privileges;
6.經過sql語句查詢出新增結果
select user,host,password from mysql.user;
7.刪除用戶
delete from user where user=‘xxx’;
flush privileges;
8.刪除數據庫
drop database dbtest;
9.修改密碼
update mysql.user set password=password(‘新密碼’) where User='xxx' and Host='localhost';flush privileges;