mysql全域性層級授權方法 mysql使用者授權問題

2021-10-18 09:58:00 字數 1525 閱讀 5624

一、mysql許可權控制包含兩個階段

檢查使用者是否能夠連線

檢查使用者是否具有所執行動作的許可權

mysql 授予許可權可分為以下幾個層級

全域性層級

資料庫層級

表層級列層級

子程式層級*

二、建立使用者及授權

2.1建立乙個使用者及密碼

create user 『『 @『localhost『 identified by 『password『;

如create user 『jinyang『 @『localhost『 identified by 『123456『;

2.2 grant授權

grant all privileges on db1.* to 『jinyang『 @『localhost『; #新建表db1,並授權使用者 jinyang對錶db1擁有所以許可權。

2.3 運維人員常用的方法

grant all privileges on . to [email protected] identified by『password『;

授權命令 對應許可權 目標:庫和表 使用者名稱和客戶端主機 使用者名稱的密碼

例:建立cango使用者,對test庫具備所有許可權,允許從localhost主機登陸管理資料庫,密碼是123456.

grant all privileges on test.* to [email protected] identified by 『123456『;

注:這裡的localhost可以是主機名;ip;ip段(如192.168.1.%)。

檢視許可權

show grants for [email protected];

例項 授權

1.檢視使用者,主機,密碼

select user,host,password from mysql.user;

2.privileges code表示授予的許可權型別,常用的有以下幾種型別:

all privileges:所有許可權。

select:讀取許可權。

delete:刪除許可權。

update:更新許可權。

create:建立許可權。

drop:刪除資料庫、資料表許可權。

[email protected]伺服器並授予delete,update,create,drop的許可權

兩種方法,第一種先建使用者在授權

create user [email protected] identified by 『jinyang『;

grant delete,update,create,drop on anchnet.ba to [email protected] ;

第二種是一步到位

grant delete,update,create,drop on 『anchnet『.『ba『 to [email protected] identified by 『jinyang『;

注:這裡可以根據使用者需求設定讀,刪,改,查的許可權。

4.檢視使用者許可權

show grants for [email protected];*

原文:

MySQL中使用者授權 刪除授權的方法

使用者授權方法 你可以通過發出grant語句增加新使用者 如下 複製 shell mysql user root mysql mysql grant all privileges on to monty localhost identified by something with grant opt...

MySQL中使用者授權以及刪除授權的方法

使用者授權方法 你可以通過發出grant語句增加新使用者 shell mysql user root mysql mysql grant all privileges on to monty localhost identified by something with grant option my...

遠端連線mysql 授權方法詳解

今在伺服器上 有mysql 資料庫,遠端訪問,不想公布root賬戶,所以,建立了demo賬戶,允許demo賬戶在任何地方都能訪問mysql資料庫中shandong庫。方案一 在安裝mysql的機器上執行 1 建立user使用者 create user demo identified by 12345...