關於修改 資料庫 遠端許可權 的一些事情

2021-09-25 19:37:36 字數 1246 閱讀 8239

grant all privileges on . to 『root』@』%』 identified by 『密碼』;

示例grant all privileges on . to 『root』@』%』 identified by 『123.com』;

(庫).(表)

*.*表示所有庫所有表

flush privileges;

在我們使用mysql資料庫時,有時我們的程式與資料庫不在同一機器上,這時我們需要遠端訪問資料庫。預設狀態下,mysql的使用者沒有遠端訪問的許可權。

下面介紹兩種方法,解決這一問題。

1、改表法

可能是你的帳號不允許從遠端登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 「mysql」 資料庫裡的 「user」 表裡的 「host」 項,從"localhost"改稱"%"?1

234mysql -u root -p

mysql>use mysql;

mysql>update user set host = 『%』 where user = 『root』;

mysql>select host, user from user;

2、授權法

在安裝mysql的機器上執行:

1、d:\mysql\bin>mysql -h localhost -u root

//這樣應該可以進入mysql伺服器

2、mysql>grant all privileges on . to 『root』@』%'with grant option

//賦予任何主機訪問資料的許可權

例如,你想myuser使用mypassword從任何主機連線到mysql伺服器的話。?1

2grant all privileges on . to 『myuser』@』%'identified by 『mypassword』 wi

th grant option;

如果你想允許使用者myuser從ip為192.168.1.6的主機連線到mysql伺服器,並使用mypassword作為密碼?1

2grant all privileges on . to 『myuser』@'192.168.1.3』identified by

『mypassword』 with grant option;

3、mysql>flush privileges

//修改生效

4、mysql>exit

退出mysql伺服器,這樣就可以在其它任何的主機上以root身份登入

Linux修改資料庫的訪問許可權

以下方法可以幫助你解決這個問題了,下面的語句功能是,建立乙個使用者為monitor密碼admin許可權為和root一樣。允許任意主機連線。這樣你可以方便進行在本地遠端運算元據庫了。create user monitor identified by admin grant all privileges...

mysql修改資料庫與級別 修改資料庫的相容級別

語法 alter database database name set compatibility level 引數database name 要修改的資料庫的名稱。compatibility level 要使資料庫與之相容的 sql server 版本。該值必須為下列值之一 80 sql serv...

修改資料 如何批量修改資料庫中的資料

如何在資料庫中動態刪除和建立資料表 第14講 在已有的資料表中刪除 新增 修改欄位的方法 第21講 根據工作表中的資料,生成資料庫中新的資料表的方法 第22講 向乙個已有的資料表中新增資料記錄的方法 第23講 把工作表中提供的資料在資料表中逐一刪除 可以是重複的記錄 的通用方法 第24講 把工作表中...