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.做映射。在默认域名的地方点击花生壳管理添加映射。点击当前主机。内网任何端口映射,获取外网随机端口,点击确认。