mysql新增使用者並授權 Mysql新增使用者並授權

2021-10-25 14:47:26 字數 1229 閱讀 1646

mysql新增使用者並授權

1.使用root使用者登入mysql資料庫,切換到mysql資料庫。

mysql -u使用者名稱 -p密碼

2.新增使用者

//只允許指定ip連線

create user '新使用者名稱'@'localhost' identified by '密碼';

//允許所有ip連線(用萬用字元%表示)

create user '新使用者名稱'@'%' identified by '密碼';

3.為使用者授權

//基本格式如下

grant all privileges on 資料庫名.表名 to '新使用者名稱'@'指定ip' identified by '新使用者密碼' ;

//示例

//允許訪問所有資料庫下的所有表

grant all privileges on *.* to '新使用者名稱'@'指定ip' identified by '新使用者密碼' ;

//指定資料庫下的指定表

grant all privileges on test.test to '新使用者名稱'@'指定ip' identified by '新使用者密碼' ;

4.設定使用者操作許可權

//設定使用者擁有所有許可權也就是管理員

grant all privileges on *.* to '新使用者名稱'@'指定ip' identified by '新使用者密碼' with grant option;

//擁有查詢許可權

grant select on *.* to '新使用者名稱'@'指定ip' identified by '新使用者密碼' with grant option;

//其它操作許可權說明,select查詢 insert插入 delete刪除 update修改

//設定使用者擁有查詢插入的許可權

grant select,insert on *.* to '新使用者名稱'@'指定ip' identified by '新使用者密碼' with grant option;

//取消使用者查詢的查詢許可權

revoke select on what from '新使用者名稱';

5.刪除使用者

drop user username@localhost;

6.修改後重新整理許可權

flush privileges;

mysql新增使用者並授權

新增使用者並授權 1 新增任何機器都能登入的使用者 grant all privileges on dbname.to test identified by 1111 2 新增172.16.184.233機器登入的使用者 grant all on dbname.to test 172.16.184....

mysql新增使用者並授權

新增使用者並授權 1 新增任何機器都能登入的使用者 grant all privileges on dbname.to test identified by 1111 2 新增172.16.184.233機器登入的使用者 grant all on dbname.to test 172.16.184....

新增MySql使用者並授權

新增mysql使用者並授權 如何解決客戶端與伺服器端的連線 mysql is not allowed to connect to this mysql server mysql connect error is not allowed to connect to this mysql server ...