mysql遠端伺服器訪問資料庫

2021-09-08 19:45:08 字數 1026 閱讀 2416

建立乙個mysql使用者,並設定可以遠端訪問

grant usage on *.* to 'fred'@'localhost' identified by 'fred';//建立使用者fred密碼ferd

select host,user,password from mysql.user where user='fred';//檢視記錄

grant all privileges on *.* to fred@'%'identified by 'fred';//設定可以遠端訪問

解決方法:

1、改表法:

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

x:\>mysql -u root -pvmware

mysql> use mysql;

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

mysql> select host, user from user;

mysql> flush privileges;

注:mysql> flush privileges; 使修改生效。

2、授權法:

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

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

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

mysql> grant all privileges on *.* to 'myuser'@'192.168.1.3' identified by 'mypassword』 with grant option;

mysql伺服器遠端訪問

mysql預設是不允許外部ip通過root使用者訪問本地資料庫伺服器,可以通過下面的語句設定,讓外部ip訪問本地mysql資料庫伺服器 grant all on to username identified by password with grant option flush privileges...

遠端linux伺服器mysql資料庫定期備份和刪除

網上已經有部分關於 linux下定期備份mysql的方法,但是很多步驟不夠詳細,不適合新手,自己琢磨了很久,終於搞定了。1.linux伺服器一般是ssh協議,如果本地也是linux環境,可以直接通過shell連線,命令 ssh l root p 8080 202.其中root為使用者名稱,一般為ro...

遠端連線伺服器的MySQL資料庫

遠端連線伺服器的mysql資料庫,錯誤 是1130,是由於無法給遠端連線的使用者許可權的問題 解決方法 本機登陸mysql後,將mysql資料庫中的user表中的host項,從localhost改為 1 以許可權使用者root登入 mysql uroot p 2 選擇mysql資料庫 use mys...