mysql授權登入命令 MYSQL遠端登陸設定命令

2021-10-19 19:31:42 字數 2092 閱讀 6526

mysql預設關閉遠端登入許可權,如下操作允許使用者在任意地點登入:

1. 進入mysql,grant all privileges on *.* to'root'@'%'identified by '' with grant option;identified by後跟的是密碼,可設為空。

2. flush privileges; 更新

mysql為了安全性,在預設情況下使用者只允許在本地登入,可是在有此情況下,還是需要使用使用者進行遠端連線,因此為了使其可以遠端需要進行如下操作:

一、允許root使用者在任何地方進行遠端登入,並具有所有庫任何操作許可權:在本機先使用root使用者登入mysql:

mysql -u root -p"youpassword"

進行授權操作:

mysql>grant all privileges on *.* to'root'@'%'identified by 'youpassword' with grant option;

過載授權表:

flush privileges;

退出mysql資料庫:

exit

二、允許root使用者在乙個特定的ip進行遠端登入,並具有所有庫任何操作許可權:

在本機先使用root使用者登入mysql:

mysql -u root -p"youpassword"

進行授權操作:

grant all privileges on *.* toroot@"172.16.16.152" identified by "youpassword" with grant option;

過載授權表:

flush privileges;

退出mysql資料庫:

exit

三、允許root使用者在乙個特定的ip進行遠端登入,並具有所有庫特定操作許可權:

在本機先使用root使用者登入mysql:

mysql -u root -p"youpassword"

進行授權操作:

grant select,insert,update,delete on *.* toroot@"172.16.16.152" identified by "youpassword";

過載授權表:

flush privileges;

退出mysql資料庫:

exit

四、刪除使用者授權,需要使用revoke命令:revoke privileges on 資料庫[.表名] from user-name;

具體例項,先在本機登入mysql:

mysql -u root -p"youpassword"

進行授權操作:

grant select,insert,update,delete on test-db totest-user@"172.16.16.152" identified by "youpassword";

再進行刪除授權操作:

revoke all on test-db from test-user;

*****************************最後從使用者表內清除使用者:

delete from user where user="test-user";

過載授權表:

flush privileges;

退出mysql資料庫:

exit

五、mysql許可權詳細分類:全域性管理許可權:

file: 在mysql伺服器上讀寫檔案。

process: 顯示或殺死屬於其它使用者的服務執行緒。

reload: 過載訪問控制表,重新整理日誌等。

shutdown: 關閉mysql服務。

資料庫/資料表/資料列許可權:

alter: 修改已存在的資料表(例如增加/刪除列)和索引。

create: 建立新的資料庫或資料表。

delete: 刪除表的記錄。

drop: 刪除資料表或資料庫。

index: 建立或刪除索引。

insert: 增加表的記錄。

select: 顯示/搜尋表的記錄。

update: 修改表中已存在的記錄。

特別的許可權:all: 允許做任何事(和root一樣)。

usage: 只允許登入--其它什麼也不允許做。

mysql遠端登入授權

mysql為了安全性,在預設情況下使用者只允許在本地登入,可是在有此情況下,還是需要使用使用者進行遠端連線,因此為了使其可以遠端需要進行如下操作 允許root使用者在任何地方進行遠端登入,並具有所有庫任何操作許可權,具體操作如下 在本機先使用root使用者登入 mysql mysql u root ...

mysql 授權使用者登陸 mysql授權登入使用者

建立使用者並授權 create user voctrals identified by some password 允許遠端訪問 grant all privileges on to voctrals identified by some password with grant option 如果想...

關於MYSQL 遠端登入的授權方法 命令

預設是不允許遠端連線的,因為有很大的安全隱患。需要手動增加可以遠端訪問資料庫的使用者。方法一 本地登入mysql,更改 mysql 資料庫裡的 user 表裡的 host 項,將 localhost 改為 mysql u root proot mysql use mysql mysql update...