mysql域名訪問資料庫
㈠ 濡備綍瑙e喅灞鍩熺綉鍐卪ysql鏁版嵁搴撹繛鎺ユ參_MySQL
閫氳繃鍐呯綉榪炲彟澶栦竴鍙版満鍣ㄧ殑mysql鏈嶅姟錛 紜鍙戠幇閫熷害N鎱錛 絳変簡澶х害鍑犲嶮縐掓墠絳夊埌鎻愮ず杈撳叆瀵嗙爜銆 浣嗘槸ping mysql鎵鍦ㄦ湇鍔″櫒鍗村緢蹇錛 鎯沖埌寰堜箙涔嬪墠鏈夎繃綾諱技鐨勭粡楠岋紝 telnet絳変竴浜涙湇鍔″湪榪炴帴璇鋒眰鐨勬椂鍊欙紝浼氬仛涓浜涘弽鍚戝煙鍚嶈В鏋愶紙濡傛灉鍙嶅悜瑙f瀽涓嶉『鐣咃紝 浼拌″氨浼氬歡榪熷緢澶氾紝 緇欎漢鐨勬劅瑙夋槸榪炴帴閫熷害N鎱錛侊級
鍦ㄧ綉涓婃悳緔浜嗕笅瑙e喅鍔炴硶錛 鍙戠幇鏈変袱縐嶏細
涓. 涓よ竟鏈哄櫒閰嶇疆鐨剅esolve.conf涓嶄竴鏍鳳紝 鎶妑esolve.conf閰嶇疆鎴愰熷害姣旇緝蹇鐨凞NS灝監K
浜. 鎶妋ysql閰嶇疆涓鐨凞NS鍙嶅悜瑙f瀽鍏蟲帀錛 涔烵K
鎴戠敤鐨勬槸絎涓縐嶅姙娉曪紝 淇鏀箁esolve.conf閰嶇疆鍚庯紝 閫熷害灝變笂鏉ヤ簡錛
闄勪竴錛 鎽樿嚜http://gcoder.blogbus.com/logs/31907502.html
涓ゅ彴鍦ㄥ悓涓緗戞電殑鏈哄櫒, 榪炴帴鍚屼竴涓鏁版嵁搴撴湇鍔″櫒, 涓鍙扮殑閫熷害鏄鍙︿竴鍙扮殑100鍊, 鏁版嵁搴撲富鏈烘槸鍩熷悕琛ㄧず鐨. 鎬庝箞閮芥兂涓嶆槑鐧?
鍚庢潵鏌ョ湅涓ゅ彴鏈哄櫒鐨 /etc/resolv.conf, 鍙戠幇閰嶇疆涓嶄竴鏍, 鏀規垚閫熷害蹇鐨勯偅鍙版満鍣ㄧ殑閰嶇疆, 閫熷害閭d笂灝變笂鏉ヤ簡.
鍩熷悕瑙f瀽涔熷彲浠ュ艱嚧緗戠粶紼嬪簭鎱, 鍙堜竴鏀惰幏. 鍙﹀, mysql榪樻湁DNS鍙嶅悜瑙f瀽鐨勯棶棰, 涔熷彲鑳藉艱嚧閫熷害鎱, 鍙浠ュ湪mysql鐨勯厤緗鏂囦歡涓, 鎶奃NS鍙嶅悜瑙f瀽鍏蟲帀.
闄勪簩錛 鎽樿嚜
褰撹繙紼嬭塊棶mysql鏃訛紝mysql浼氳В鏋愬煙鍚嶏紝浼氬艱嚧璁塊棶閫熷害寰堟參錛屽姞涓婁笅闈㈣繖涓閰嶇疆鍙瑙e喅姝ら棶棰
# 紱佹mysql鍋氬煙鍚嶈В鏋
[mysqld]
skip-name-resolve
php榪滅▼榪炴帴MYSQL閫熷害鎱,鏈夋椂榪滅▼榪炴帴鍒癕YSQL鐢ㄦ椂4-20縐掍笉絳,鏈鍦拌繛鎺MYSQL姝e父,鍑虹幇榪欑嶉棶棰樼殑涓昏佸師鍥犳槸,榛樿ゅ畨瑁呯殑MYSQL寮鍚浜咲NS鐨勫弽鍚戣В鏋,鍦∕Y.INI(WINDOWS緋葷粺涓)鎴朚Y.CNF(UNIX鎴朙INUX緋葷粺涓)鏂囦歡鐨刐mysqld]涓嬪姞鍏skip-name-resolve榪欎竴鍙ャ
浣嗘槸錛岃繖鏍蜂細寮曡搗涓涓闂棰橈細榪炴帴mysql鏃訛紝涓嶈兘浣跨敤 localhost榪炴帴浜嗭紝鑰屾槸瑕佷嬌鐢↖P鍦板潃鐨勶紱濡傛灉鏄鎸塴ocalhost瀵圭敤鎴瘋祴鏉冮檺鐨勮瘽錛岀敤鎴風櫥褰曟潈闄愪篃瑕佷慨鏀逛竴涓嬬殑銆
榪炴帴mysql閫熷害鎱㈢殑瑙e喅鏂規硶.
2鍙版湇鍔″櫒錛屼竴鍙拌窇iis+php錛屼竴鍙拌窇mysql錛屽拰浠ュ線涓鏍烽厤緗濂界幆澧冿紝嫻嬭瘯欏甸潰涓鍒嘜K
璺戝簲鐢ㄧ殑鏃跺欏彂鐜皃hp璁塊棶mysql閫熷害寰堟參錛岃繖縐嶆儏鍐靛湪浠ュ墠浠庢湭鍙戠幇榪囷紝鉶界劧2鍙版湇鍔″櫒騫墮潪鍦ㄥ悓涓緗戞典腑錛屼絾鏄痯ing鏁板煎熀鏈涓婇兘鍦1,2ms涔嬮棿錛宼cp榪炴帴搴旇ヤ笉鏄闂棰樺叧鍋ワ紝google浠ュ悗鎵懼埌絳旀堬紝鍦╩y.ini鏂囦歡鐨刐mysqld]閮ㄥ垎鍔犲叆:skip-name-resolve錛屼繚瀛樻枃浠訛紝閲嶅惎mysql錛屼竴鍒嘜K鍟︼紝閫熷害璞¢炰竴鏍蜂簡
鏂扮増鏈鐨刴ysql閰嶇疆璧鋒潵涓嶈薄浠ュ墠鐨勯偅涓鍌葷摐鍖栦簡錛岃繖涓闂棰樻姌鑵句簡鎴戜竴涓婂崍鐨勬椂闂達紝鏅氫笂鍥炴潵鎬葷畻鏄瑙e喅浜嗭紝鍢垮樋錛屽張瀛﹀埌涓浜涗笢瑗褲
Windows 2003涓嬬殑MySQL 5鏈嶅姟鍣錛屾湰鏈鴻繛鎺ュ埌MySQL鏈嶅姟闈炲父蹇錛屽矓鍩熺綉鍐呮湁涓ゅ彴Linux鏈哄櫒錛屾湁涓鍙拌繛鎺ュ緢蹇錛屽彟澶栦竴鍙拌緭鍏ュ瘑鐮佸悗瑕佺瓑濂藉嚑縐掗挓鎵嶈兘榪炰笂銆
瑙e喅鍔炴硶錛
鍦∕ySQL鏈嶅姟鍣ㄧ殑閰嶇疆涓澧炲姞涓涓濡備笅閰嶇疆鍚庨熷害椋炲揩銆
[mysqld]
skip-name-resolve
闄勫綍錛( How MySQL uses DNS )
When a new thread connects to mysqld, mysqld will spawn a new thread to handle the request. This thread will first check if the hostname is in the hostname cache. If not the thread will call gethostbyaddr_r() and gethostbyname_r() to resolve the hostname.
If the operating system doesn't support the above thread-safe calls, the thread will lock a mutex and call gethostbyaddr() and gethostbyname() instead. Note that in this case no other thread can resolve other hostnames that is not in the hostname cache until the first thread is ready.
You can disable DNS host lookup by starting mysqld with --skip-name-resolve. In this case you can however only use IP names in the MySQL privilege tables.
If you have a very slow DNS and many hosts, you can get more performance by either disabling DNS lookop with --skip-name-resolve or by increasing the HOST_CACHE_SIZE define (default: 128) and recompile mysqld.
You can disable the hostname cache with --skip-host-cache. You can clear the hostname cache with FLUSH HOSTS or mysqladmin flush-hosts.
If you don't want to allow connections over TCP/IP, you can do this by starting mysqld with --skip-networking.
PHP榪滅▼榪炴帴MYSQL閫熷害鎱,鏈夋椂榪滅▼榪炴帴鍒癕YSQL鐢ㄦ椂4-20縐掍笉絳,鏈鍦拌繛鎺MYSQL姝e父,鍑虹幇榪欑嶉棶棰樼殑涓昏佸師鍥犳槸,榛樿ゅ畨瑁呯殑MYSQL寮鍚浜咲NS鐨勫弽鍚戣В鏋,鍦∕Y.INI(WINDOWS緋葷粺涓)鎴朚Y.CNF(UNIX鎴朙INUX緋葷粺涓)鏂囦歡鐨刐mysqld]涓嬪姞鍏skip-name-resolve榪欎竴鍙ャ
MYSQL榪滅▼榪炴帴閫熷害鎱㈢殑瑙e喅鏂規硶
鍦ㄥ矓鍩熺綉鍐呰繛鎺ュ叾浠栨満鍣ㄧ殑MYSQL,鍙戠幇閫熷害鎱㈢殑寰,涓嶇煡閬撲粈涔堝師鍥,鎬繪湁鍑犵掔殑寤惰繜.
鍚庢潵鍦ㄧ綉涓婂彂鐜拌В鍐蟲柟娉,my.ini閲岄潰娣誨姞
[mysqld]
skip-name-resolve
skip-grant-tables
榪欐牱閫熷害灝卞揩浜!
skip-name-resolve
閫夐」灝辮兘紱佺敤DNS瑙f瀽錛岃繛鎺ラ熷害浼氬揩寰堝氥備笉榪囷紝榪欐牱鐨勮瘽灝變笉鑳藉湪MySQL鐨勬巿鏉冭〃涓浣跨敤涓繪満鍚嶄簡鑰屽彧鑳界敤ip鏍煎紡銆
鑻ヤ嬌鐢╛skip-grant-tables緋葷粺灝嗗逛換浣曠敤鎴風殑璁塊棶涓嶅仛浠諱綍璁塊棶鎺у埗錛屼絾鍙浠ョ敤 mysqladmin flush-privileges鎴杕ysqladmin reload鏉ュ紑鍚璁塊棶鎺у埗;榛樿ゆ儏鍐墊槸show databases璇鍙ュ規墍鏈夌敤鎴峰紑鏀撅紝濡傛灉mysql鏈嶅姟鍣ㄦ病鏈夊紑榪滅▼甯愭埛錛屽氨鍦╩y.ini閲岄潰鍔犱笂skip-grant-tables
默認情況下,mysql資料庫用的是3306的埠,你只要在路由器里把3306埠映射到mysql 伺服器的IP就可以了, 你外網訪問時直接訪問路由器的外網地址+埠號就行了。路由器可以用花生殼來實現外網地址和域名的轉換。最終你訪問就是: 」花生殼的域:3306「就可以了。
㈢ mysql想讓外網的訪問,mysql不支持域名嗎
mysql user表裡面 想讓外網訪問的賬號 host那行改成 '%'
㈣ 路由器分配的是動態公網IP,且有路由器登錄管理許可權。如何實現外網訪問內網MySQL資料庫
在路由器配置DDNS,並填上DDNS的服務提供商的賬號:(需要注冊)
如華為AR系列路由器的界面如下:
然後把MySQL的埠TCP3306映射出去即可。
㈤ 哪位大神可以簡單說一下外網訪問內網MySQL資料庫的步驟嗎
1,明確MySQL資料庫內網訪問地址埠,確保MySQL資料庫服務正常,在內網可以正常訪問連接。如我本機MySQL資料庫訪問地址是localhost:3306。
2.內網使用花生殼動態域名解析,內網伺服器安裝花生殼,並使用它。
3.使用自己的帳號登錄。如沒有帳號,「注冊帳號」進入網站進行注冊帳號。正常登錄後,會顯示登錄帳號下的域名。
4.做映射。在默認域名的地方點擊花生殼管理添加映射。點擊當前主機。內網任何埠映射,獲取外網隨機埠,點擊確認。