遠端訪問mysql

2021-08-26 06:45:22 字數 1092 閱讀 9601

mysql-----

0.檢視所有使用者: select distinct concat('user: ''',user,'''@''',host,''';') as query from mysql.user

1.新增:

create user  'duobaohui

'@'223.4.246.239

' identified by 'password'; 

2.賦權:grant all privileges on heshangmeng.* to '

duobaohui

'@'223.4.246.239';

3.重新整理:flush privileges;

223.4.。。 是訪問者,不是mysql所在伺服器, 內網換成 %

linux-------

修改防火牆配置檔案:

vi /etc/sysconfig/iptables

增加下面一行:

-a rh-firewall-1-input -m state –state new -m tcp -p tcp –dport 3306 -j accept

如果想開通21等埠,只需要將3306換成21等要開放的埠就可以了。

配置後,重新啟動iptable

serviceiptablesrestart

這時就可以從其他機器訪問mysql了。

注意:

-a rh-firewall-1-input -m state --state new -m tcp -p tcp --dport 3306 -j accept

-a rh-firewall-1-input -j reject --reject-with icmp-host-prohibited

-a   rh-firewall-1-input   -j   reject   --reject-with   icmp-host-prohibited 

是拒絕icmp訪問,對於其它的報文返回乙個主機禁止訪問的錯誤

開通3306 埠的行必須在icmp-host-prohibited前

遠端訪問mysql 程式 遠端訪問MySQL

1.確保server端允許被遠端訪問及防火牆放行。確保server端mysql庫中user表中包含host為client端ip資料條目,另外需要知道user和password內容,若沒有可人為新增 按照常理只要host項中包含 就代表允許任何client訪問,但是我的卻沒有成功,只好新增特定ip 在...

mysql 開啟遠端訪問 遠端訪問

select host,user,password from user 查詢使用者遠端訪問相關資訊 用root使用者登陸,然後 grant all privileges on to 建立的使用者名稱 identified by 密碼 flush privileges 重新整理剛才的內容 格式 gra...

mysql 遠端訪問

報類似這樣的 error 1130 host 192.168.1.3 is not allowed to connect to this mysql server 解決辦法 user表裡host列,表明的是使用者可登陸的計算機名,所以辦法有 1,改表 在localhost的那台電腦,登入mysql後...