mysql mariadb授權管理

2021-10-04 18:06:48 字數 1535 閱讀 1987

授權語句如下:

grant

all[

privileges

]on db.tbl to

'username'@'host' identified by 'password';

db表示資料庫名字,可以使用*通配,tbl為表的名稱,也可以使用萬用字元。

例:給本地使用者授權某個資料庫的所有許可權

grant

allprivileges

on test.

*to username@localhost identified by

'123456'

;grant

allprivileges

on test.

*to [email protected] identified by

'123456'

;

注意:username@localhost和[email protected] mysql會認為這是兩個使用者。privileges可以省略不寫。

例:給遠端使用者授權

grant

allprivileges

on test.

*to username@'192.168.%

.%' identified by '

123456';

flush privileges

;

也可以針對使用者授權某個數庫的某些許可權,如查詢,刪除等等。

例:授權使用者username在資料庫test中的查詢許可權

grant

select

on test.

*to username@'192.168.%

.%' identified by '

123456';

當建立使用者時會自動授權使用者usage許可權,該許可權只能用於登入資料庫,不能用於其他操作。

grant

select

on test.

*to username@'192.168.%

.%' identified by '

123456' with

grant

option

;

以使用者角度看,也就是查某使用者對哪些資料庫有哪些許可權

show grants for [email protected]

;

以資料庫角度看,也就是檢視該資料庫對哪些使用者有授權

select

*from mysql.db where db=

"你要檢視的資料庫"

revoke

"要移除的許可權"

on 資料庫.表 from 使用者@host

;

centos 解除安裝mysql mariadb

1 檢查安裝包情況 命令 rpm qa grep i mysql root db1 rpm qa grep i mysql mysql libs 5.1.73 7.el6.x86 64 2 解除安裝 命令 rpm e mysql libs 5.1.73 7.el6.x86 64 root db1 r...

修改MySql MariaDB密碼

二 忘記原密碼進行修改 1 使用set password命令修改密碼 set password在mysql中修改中修改密碼 mysql uroot p 輸入原密碼 mariadb none set password for root localhost password newpassword ma...

mysql mariadb編碼修改

修改mariadb的資料儲存路徑和預設字符集 vi etc my.cnf 修改 mysqld 下面的datadir路徑,並新增字符集配置 skip name resolve character set server utf8mb4 collation server utf8mb4 unicode c...