mysql筆記 許可權

2021-07-11 15:38:41 字數 1288 閱讀 4363

meng@localhost表示建立的賬戶只能在本機登入

grant只能建立有密碼的賬戶。,不然會報1033錯誤 

grant建立賬戶

grant all privileges on *.* to meng@localhost identified by '123' with grant option;

all privileges這個許可權不要亂用,許可權好高的

如果需要乙個空密碼或者無密碼的賬戶,必須先用create user命令,然後通過 

grant來分配許可權。

建立賬號,賦予crud許可權,從任何ip登入,密碼123

grant select,insert,update,delete on test1.* to 'z2'@'%' identified by '123

收回許可權

revoke select,insert on *.* from meng@localhost;

檢視 賬號許可權

show grants for meng@localhost;

授予管理許可權

grant super,process,file on *.* to 'z3'@'%';

只授予登入許可權

grant usage on *.* to 'z4'@'localhost';

修改密碼:

第一種:

shell>mysqladmin -u user_name -h host_name password "newpwd";

方法2:

mysql>set password for 'meng'@'%' = password('laomeng123');

方法3:

grant usage on *.* to 'meng'@'%' identified by 'laomeng123';

改完密碼後flush privileges;重新整理使用者許可權

可以用md5來代替明文密碼

刪除賬號:

drop user meng@localhost;

或者use mysql;

delete from user where user='meng'

mysql賬號還支援賬號資源限制,比如單個賬號每小時執行的查詢次數;比如單個賬號每小時執行的更新次數;每小時連線伺服器次數;

不要把super、process和file授予管理員以外的角色

super能執行kill直接關程序,pocess能鎖定程序,能造成管理員密碼被直接修改

顯示innodb狀態及錯誤狀態

show engine innodb status\g

mysql 重新整理許可權 mysql許可權

1,檢視所有使用者許可權 select distinct concat user user,host,as query from mysql.user 或者 select from mysql.user 2,檢視某乙個使用者的許可權 show grants for user ip 3,分配許可權 以...

mysql許可權 列許可權 mysql 的許可權體系介紹

mysql 的許可權體系大致分為5個層級 全域性層級 全域性許可權適用於乙個給定伺服器中的所有資料庫。這些許可權儲存在mysql.user表中。grant all on 和revoke all on 只授予和撤銷全域性許可權。資料庫層級 資料庫許可權適用於乙個給定資料庫中的所有目標。這些許可權儲存在...

mysql 許可權設定 mysql 許可權設定

關於mysql的使用者管理,筆記 1 建立新使用者 通過root使用者登入之後建立 grant all privileges on to testuser localhost identified by 123456 建立新使用者,使用者名為testuser,密碼為123456 grant all ...