mysql 建立使用者和授權

2021-09-02 01:13:08 字數 1526 閱讀 6413

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 all on maindataplus.* 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建立使用者和授權

我們知道我們的最高許可權管理者是root使用者,它擁有著最高的許可權操作。包括select update delete update grant等操作。那麼一般情況在公司之後dba工程師會建立乙個使用者和密碼,讓你去連線資料庫的操作,並給當前的使用者設定某個操作的許可權 或者所有許可權 那麼這時就需...