create user 'username'@'host' identified by 'password';
create user 'dog'@'localhost' identified by '123456';
create user 'pig'@'192.168.1.101_' idendified by '123456';
create user 'pig'@'%' identified by '123456';
create user 'pig'@'%' identified by '';
create user 'pig'@'%';
grant privileges on databasename.tablename to 'username'@'host'
grant select, insert on test.user to 'pig'@'%';
grant all on *.* to 'pig'@'%';
用以上命令授權的使用者不能給其它使用者授權,如果想讓該使用者可以授權,用以下命令:
grant privileges on databasename.tablename to 'username'@'host' with grant option;
set password for 'username'@'host' = password('newpassword');
如果是當前登陸使用者用:
set password = password("newpassword");
set password for 'pig'@'%' = password("123456");
revoke privilege on databasename.tablename from 'username'@'host';
privilege, databasename, tablename:同授權部分
revoke select on *.* from 'pig'@'%';
假如你在給使用者'pig'@'%'
授權的時候是這樣的(或類似的):grant select on test.user to 'pig'@'%'
,則在使用revoke select on *.* from 'pig'@'%';
命令並不能撤銷該使用者對test資料庫中user表的select
操作。相反,如果授權使用的是grant select on *.* to 'pig'@'%';
則revoke select on test.user from 'pig'@'%';
命令也不能撤銷該使用者對test資料庫中user表的select
許可權。
具體資訊可以用命令show grants for 'pig'@'%';
檢視。
drop user 'username'@'host';
MYSQL建立使用者和授權
登入mysql 有root許可權 mysql u root p 密碼 建立使用者 mysql mysql insert into mysql.user host,user,password,ssl cipher,x509 issuer,x509 sub ject values localhost p...
Mysql建立使用者和授權
假設使用者名稱是yanzi,密碼是 123456 1.建立使用者 create user yanzi identified by 123456 2.授權 左邊的星號表示database,右邊的星號是table.grant select,insert,update,delete on to yanzi...
mysql 建立使用者和授權
create user username host identified by password create user dog localhost identified by 123456 create user pig 192.168.1.101 idendified by 123456 cre...