dbo 发表于 2014-8-26 14:42:47

请问下关于树莓派MYSQL局域网访问的问题

MYSQL用户IP已经修改为% 但是局域网访问不了 是不是防火墙的问题 我参考过debian关闭防火墙的命令 提示没有这个服务什么的

wing 发表于 2014-8-26 20:38:42

本机能访问么?
我印象中raspbian是没有防火墙的,随便一个端口开了就可以访问

dbo 发表于 2014-8-26 22:22:48

本机是可以访问的

dbo 发表于 2014-8-26 22:25:41

wing 发表于 2014-8-26 20:38 static/image/common/back.gif
本机能访问么?
我印象中raspbian是没有防火墙的,随便一个端口开了就可以访问

本机可以访问 本机登陆的时候我就把ROOT的IP改为%没用 然后又新建了一个用户 改%也没用

wing 发表于 2014-8-27 12:21:15

那就奇异果了,你不如指定一个内网IP然后试下能不能访问

dbo 发表于 2014-8-27 12:32:34

wing 发表于 2014-8-27 12:21 static/image/common/back.gif
那就奇异果了,你不如指定一个内网IP然后试下能不能访问

也试过了 也连不上

dbo 发表于 2014-8-27 13:00:52


iptables v1.4.14

Usage: iptables - chain rule-specification
       iptables -I chain rule-specification
       iptables -R chain rulenum rule-specification
       iptables -D chain rulenum
       iptables - ]
       iptables -
       iptables - chain
       iptables -E old-chain-name new-chain-name
       iptables -P chain target
       iptables -h (print this help information)

Commands:
Either long or short options are allowed.
--append-A chain            Append to chain
--check   -C chain            Check for the existence of a rule
--delete-D chain            Delete matching rule from chain
--delete-D chain rulenum
                              Delete rule rulenum (1 = first) from chain
--insert-I chain
                              Insert in chain as rulenum (default 1=first)
--replace -R chain rulenum
                              Replace rule rulenum (1 = first) in chain
--list    -L ]
                              List the rules in a chain or all chains
--list-rules -S ]
                              Print the rules in a chain or all chains
--flush   -F           Delete all rules inchain or all chains
--zero    -Z ]
                              Zero counters in chain or all chains
--new   -N chain            Create a new user-defined chain
--delete-chain
            -X           Delete a user-defined chain
--policy-P chain target
                              Change policy on chain to target
--rename-chain
            -E old-chain new-chain
                              Change chain name, (moving any references)
Options:
    --ipv4      -4            Nothing (line is ignored by ip6tables-restore)
    --ipv6      -6            Error (line is ignored by iptables-restore)
[!] --proto   -p proto      protocol: by number or name, eg. `tcp'
[!] --source    -s address[...]
                              source specification
[!] --destination -d address[...]
                              destination specification
[!] --in-interface -i input name[+]
                              network interface name ([+] for wildcard)
--jump -j target
                              target for rule (may load target extension)
--goto      -g chain
                              jump to chain with no return
--match       -m match
                              extended match (may load extension)
--numeric   -n            numeric output of addresses and ports
[!] --out-interface -o output name[+]
                              network interface name ([+] for wildcard)
--table       -t table      table to manipulate (default: `filter')
--verbose   -v            verbose mode
--line-numbers                print line numbers when listing
--exact       -x            expand numbers (display exact values)
[!] --fragment-f            match second or further fragments only
--modprobe=<command>          try to insert modules using this command
--set-counters PKTS BYTES   set the counter during insert/append
[!] --version   -V            print package version.

dbo 发表于 2014-8-27 13:01:39

这个是树莓派上的防火墙帮助内容 实在看不懂不会用 高手帮忙指导一下 可以让我局域网连上MYSQL

wing 发表于 2014-8-27 23:31:28

本帖最后由 wing 于 2014-8-27 23:42 编辑

我之前在RPI上写的http服务程序是不需要对网络进行特别设置就可以被局域网访问的,但是当时我用的是root来运行的。
我见其他人都是把root和mysql两个用户都设置为%的,
不知道会不会和运行mysql的用户有关

wing 发表于 2014-8-28 00:01:13

至于那个iptables的问题嘛,我以为所有RPI是无规则的,至少默认情况下是没有,这个我回头确认下...
不过你也可以看看你的机器是不设置了规则
查看规则的命令是
iptables -L -n
然后清除所有规则的命令是
iptables -F
保存命令好像是.....save,但是我记不住那个该死的配置文件的位置,这个你可以上网查下。
最后通常都要重启服务才生效的
service iptables restart

wing 发表于 2014-8-28 00:17:24

嗯...查过了,我的RPI是这样的

Chain INPUT (policy ACCEPT)

target prot opt source destination

Chain FORWARD (policy ACCEPT)

target prot opt source destination

Chain OUTPUT (policy ACCEPT)

target prot opt source destination

没有firewall的哟,印象中我没改过规则的,这个应该就是原来的样子。

贱客 发表于 2014-8-28 10:59:45

mysqld 默认监听在 127.0.0.1

看一下配置文件
cat /etc/mysql/my.cnf |grep bind-address
默认应该是
bind-address                = 127.0.0.1

改为 0.0.0.0
重启服务

然后确认一下绑定的地址
sudo netstat -lntp

有 0.0.0.0:3306 就 ok 了。

不过为了安全性考虑,不建议绑定到所有地址上。默认 127.0.0.1 很好了。如果只是为了管理需要,可以通过 ssh 通道连接。

dbo 发表于 2014-8-28 12:37:54

用了贱客的方法连上了非常感谢两位的热心帮助

wing 发表于 2014-8-29 12:39:34

呵呵~~~
终于等到高手出现了,
我也受教啦,感谢感谢

水涌沧 发表于 2014-9-10 19:46:35

我在树梅派派上安装好mysql之后怎么都启动失败,大家有什么解决办法没有?
页: [1]
查看完整版本: 请问下关于树莓派MYSQL局域网访问的问题