mysql 創建一個用戶 hail,密碼 hail,指定一個數據庫 haildb 給 hail
mysql -u root -p
password
use mysql;
insert into user(host,user,password) values('localhost','hail',password('hail'));
flush privileges;
create database haildb;
grant all privileges on haildb.* to hail@localhost identified by'hail';
flush privileges;
如果想指定部分權限給用戶
grant select,update on haildb.* to hail@localhost identified by'hail';
flush privileges;
刪除用戶
deletefrom user where user='hail'and host='localhost';
flush privileges;
刪除用戶數據庫
drop database haildb;
修改指定用戶密碼
update user set password=password('new_password')where user='hail'and host='localhost';
flush privileges;