使用者授權和root密碼管理

2021-10-01 21:57:24 字數 2022 閱讀 4447

mysql> mysql -uroot -p******xx	#使用root連線資料庫

mysql> grant 許可權列表 on 庫.表 to 使用者名稱@'客戶端位址' identified by '***'

;#密碼需要符合密碼策略

mysql> grant 許可權列表 on 庫.表 to 使用者名稱@'客戶端位址' identified by '***' with grant option;

#給新使用者授權使用grant命令

mysql> grant 許可權列表 on 庫.表 to 使用者名稱@'%' identified by '***'

;#任意位址

mysql> grant 許可權列表 on 庫.表 to 使用者名稱@'192.168.4.%' identified by '***'

;#指定網段

mysql> grant 許可權型別(欄位1,欄位2,...) on 庫.表 to 使用者名稱@'位址' identified by '***'

;#指定字段

all //所有許可權

usage //無許可權

select,insert,delete //個別許可權

select,update(欄位1,欄位2,…) //指定字段

mysql>

select user();

#檢視登入使用者名稱及位址

mysql> show grants;

#檢視當前使用者的許可權

mysql> show grants for 使用者名稱@'位址'

;# 管理員檢視授權

mysql>

set password=password(

"******x");

#被授權的使用者修改自己的密碼

mysql>

set password for 使用者名稱@'位址'

=password(

"******x");

#管理員修改使用者密碼

mysql> drop user 使用者名稱@'位址'

;#管理員刪除使用者

mysql庫,記錄授權資訊

可以通過表記錄檢視使用者許可權,也可以通過更新記錄修改使用者許可權

mysql> update mysql.user set delete_priv=

"n" , grant_priv=

"n" where user=

"mydba" and host=

"%";

mysql> show grants for 使用者名稱@'位址'

;#檢視當前許可權

mysql> revoke 許可權列表 on 庫.表 from 使用者名稱@'位址'

;#取消授權

停止mysql程式

跳過授權表啟動mysql服務

修改root密碼

以正常方式啟動服務

] systemctl stop mysqld

] vim /etc/my.cnf

[mysqld]

skip-grant-tables #新增此行,跳過授權表

#validate_password_policy=0 #注釋密碼規則

#validate_password_length=6 #注釋密碼規則

...] systemctl restart mysqld

] mysql #連線資料庫

mysql> update mysql.user set authentication_string=password(

"密碼"

) where user=

"root" and host=

"localhost"

;#修改密碼

mysql> flush privileges;

] mysqladmin -uroot -p舊密碼 password "新密碼"

#命令列修改root密碼

mysql使用者管理,授權,重置root密碼

刪除使用者 修改使用者密碼 update user set password password 新密碼 where user 使用者名稱 update user set password password abc where user lisi set password for 使用者名稱 主機名 ...

console 密碼和使用者授權

1,如何登陸真機 交換機 console 口 管理 控制。console 線 配置線。rs232 計算機的序列介面。usb轉串列埠線 插上電腦後 securecrt 連線交換機 2,console 口 密碼 方式a 密碼驗證 user inte ce console 0 進入控制介面。authent...

mysql授權使用者和密碼

mysql授權使用者和密碼 1.用root賬號建立資料庫a.2.給其他的賬號重新設定許可權 取消全域性級別的許可權,全部換成資料庫級別 使它們不能訪問資料庫a 給使用者a f設定許可權 mysql grant all on a.to a f identified by 123456 表示任意在主機都...