无法连接从Android设备到mysql [英] can't connect to mysql from android device

查看:127
本文介绍了无法连接从Android设备到mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的平板电脑,我使用的Andr​​oid应用商店简单的应用程序到我的电脑(MySQL的经理)上访问MySQL数据库。失败说:

on my tablet, i am using a simple app from android app store to access mysql database on my PC (mysql manager). it fails saying:

error.communication故障。

error.communication failure.

成功地向服务器发送的最后分组为0毫秒以前。
司机并没有收到来自服务器的任何数据包

the last packet succesfully sent to the server was 0 milliseconds ago. the driver has not recieved any packets from the server"

我的防火墙端口3306打开。
我也曾经在MySQL中授予的权限:

my firewall port 3306 is opened. i have also granted permissions in mysql:

CREATE USER 'root'@'%' IDENTIFIED BY '1234';
FLUSH PRIVILEGES;

访问MySQL在我的电脑(本地主机),做工精细。
我的电脑是Windows 7运行,我使用的是最新的MySQL工作台(6.0版本)。
我试图通过我的Wi-Fi路由器进行连接。

access to mysql in my PC (localhost), works fine. my PC is running on windows 7 and i am using the latest mysql workbench (version 6.0). i am trying to connect through my wi-fi router.

我想给我的论文的Andr​​oid设备上的我的电脑IP地址:

i tried giving theses IPs for my PC on my android device:

127.0.0.1
10.0.0.1

可以请你告诉我还有什么我应该为了能够从我的平板电脑访问我的PC上的mysql数据库吗?

can you please advise me what else should i do in order to be able to access the mysql database on my PC from my tablet?

推荐答案

如果你的Andr​​oid设备上的 LAN网络的(可能的Wi-Fi),您必须使用局域网IP。

Solution Intranet/Lan (probably wi-fi):

If your Android Device is on LAN NetWork (probably wi-fi), you have to use the "lan ip".


  1. 让您的PC的IP(本地IP / LAN IP)(类似
    192.168.1.101或10.0.0.101或10.1.1.12)

  2. 在您的应用(Android设备)访问像192.168.1.101:3306

  3. 提示:建议设置(手动)将您的计算机IP的,因为路由器不会更改IP

有关获取IP,请参见:

For get IP, see:


  1. 开启CMD

  2. 键入IPCONFIG(不带引号)

  3. preSS输入

  4. 您的IP,子网掩码和默认网关将被退还给您

  5. 复制IP的行 IPv4地址:xxx.xxx.xxx.xxx

  6. 假设你已经返回像192.168.1.113
    你必须访问的地址到你的Android设备像这样: 192.168.1.113:3306

  1. Open CMD
  2. Type "ipconfig" (without quotation marks)
  3. Press "Enter"
  4. Your ip, subnet, mask and default gateway will be returned to you
  5. Copy IP by the line IPv4 Address: xxx.xxx.xxx.xxx
  6. Assuming you have returned something like "192.168.1.113" you must access the address to your "android device" like this: 192.168.1.113:3306

阅读本地IP /私有地址: http://en.wikipedia.org/维基/ IP_地址#IPv4_private_addresses

Read about "local ip/Private addresses": http://en.wikipedia.org/wiki/IP_address#IPv4_private_addresses

请注意:10.0.0.1,10.1.1.1,192.168.0.1,192.168.1.1距离路由器和非PC,也就是因为它们属于路由器他们将永远不会被分配到其他计算机的IP士兵

Note: 10.0.0.1, 10.1.1.1, 192.168.0.1, 192.168.1.1 are IPs privates from ROUTER and non-PC, ie they will never be assigned to other computers because they belong to the router

跑在你的电脑127.0.0.1:(port都MysqlServer和仿真器)

Emulator:

Running both MysqlServer and Emulator in you computer 127.0.0.1:(port)

在10.0.2.2(即10.0.2.2:3306)是解决这一问题。

The 10.0.2.2 (ie 10.0.2.2:3306) is the solution to that problem.

模拟器虚拟网上相同的网络,路由器在运行,即是没有的。

The emulator runs on a "virtual network", ie is not in the same network as your router.


  1. 10.0.2.1路由器/网关地址

  2. 10.0.2.2特殊别名主机回环接口(即,在开发机器上127.0.0.1)

  3. 10.0.2.3第一个DNS服务器

  4. 127.0.0.1模拟的设备自身的loopback接口

阅读: http://developer.android.com/tool​​s/devices/emulator。 HTML

127.0.0.1试图与您尝试打开,而不是PC模拟器本身模拟器访问本地主机时只访问本地主机,即

127.0.0.1 accesses only the localhost, ie when trying to access localhost with the emulator you try to open own emulator instead of the PC.

http://en.wikipedia.org/wiki/Localhost

这篇关于无法连接从Android设备到mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆