MySQl建立使用者和授權

2022-04-20 07:57:00 字數 1640 閱讀 5337

許可權的管理:

首先進去到mysql資料庫下:

mysql>use mysql

database changed

其次, 對新使用者進行增刪改:

1.建立使用者:

#指定ip:192.118.1.1的chao使用者登入

create user '

chao

'@'192.118.1.1

' identified by '

123';#

指定ip:192.118.1.開頭的chao使用者登入

create user '

chao

'@'192.118.1.%

' identified by '

123';#

指定任何ip的chao使用者登入

create user '

chao

'@'%

' identified by '

123';

2.刪除使用者

drop user

'使用者名稱

'@'ip位址';

3.修改使用者

rename user

'使用者名稱

'@'ip位址

' to '

新使用者名稱

'@'ip位址';

4.修改密碼

set password

for'

使用者名稱'@'

ip位址

'=password('

新密碼');

接著, 對當前的使用者進行授權

#

檢視許可權

show grants for'使用者

'@'ip位址'#

授權 chao使用者僅對db1.t1檔案有查詢、插入和更新的操作

grant select ,insert,update on db1.t1 to "

chao

"@'%';

#表示有所有的許可權,除了grant這個命令,這個命令是root才有的。chao使用者對db1下的t1檔案有任意操作

grant all privileges on db1.t1 to "

chao

"@'%';

#chao使用者對db1資料庫中的檔案執行任何操作

grant all privileges on db1.* to "

chao

"@'%';

#chao使用者對所有資料庫中檔案有任何操作

grant all privileges on *.* to "

chao

"@'%';

#取消許可權

#取消chao使用者對db1的t1檔案的任意操作

revoke all on db1.t1 from

'chao

'@"%";

#取消來自遠端伺服器的chao使用者對資料庫db1的所有表的所有許可權

revoke all on db1.* from

'chao

'@"%";

取消來自遠端伺服器的chao使用者所有資料庫的所有的表的許可權

revoke all privileges on *.* from

'chao

'@'%

';

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...