极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 18692|回复: 14

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

[复制链接]
发表于 2014-8-26 14:42:47 | 显示全部楼层 |阅读模式
MYSQL用户IP已经修改为% 但是局域网访问不了 是不是防火墙的问题 我参考过debian关闭防火墙的命令 提示没有这个服务什么的
回复

使用道具 举报

发表于 2014-8-26 20:38:42 | 显示全部楼层
本机能访问么?
我印象中raspbian是没有防火墙的,随便一个端口开了就可以访问
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-26 22:22:48 | 显示全部楼层
本机是可以访问的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-26 22:25:41 | 显示全部楼层
wing 发表于 2014-8-26 20:38
本机能访问么?
我印象中raspbian是没有防火墙的,随便一个端口开了就可以访问

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

使用道具 举报

发表于 2014-8-27 12:21:15 | 显示全部楼层
那就奇异果了,你不如指定一个内网IP然后试下能不能访问
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-27 12:32:34 | 显示全部楼层
wing 发表于 2014-8-27 12:21
那就奇异果了,你不如指定一个内网IP然后试下能不能访问

也试过了 也连不上
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-27 13:00:52 | 显示全部楼层

iptables v1.4.14

Usage: iptables -[ACD] chain rule-specification [options]
       iptables -I chain [rulenum] rule-specification [options]
       iptables -R chain rulenum rule-specification [options]
       iptables -D chain rulenum [options]
       iptables -[LS] [chain [rulenum]] [options]
       iptables -[FZ] [chain] [options]
       iptables -[NX] chain
       iptables -E old-chain-name new-chain-name
       iptables -P chain target [options]
       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 [rulenum]
                                Insert in chain as rulenum (default 1=first)
  --replace -R chain rulenum
                                Replace rule rulenum (1 = first) in chain
  --list    -L [chain [rulenum]]
                                List the rules in a chain or all chains
  --list-rules -S [chain [rulenum]]
                                Print the rules in a chain or all chains
  --flush   -F [chain]          Delete all rules in  chain or all chains
  --zero    -Z [chain [rulenum]]
                                Zero counters in chain or all chains
  --new     -N chain            Create a new user-defined chain
  --delete-chain
            -X [chain]          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[/mask][...]
                                source specification
[!] --destination -d address[/mask][...]
                                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.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-27 13:01:39 | 显示全部楼层
这个是树莓派上的防火墙帮助内容 实在看不懂不会用 高手帮忙指导一下 可以让我局域网连上MYSQL
回复 支持 反对

使用道具 举报

发表于 2014-8-27 23:31:28 | 显示全部楼层
本帖最后由 wing 于 2014-8-27 23:42 编辑

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

使用道具 举报

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

使用道具 举报

发表于 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 通道连接。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-28 12:37:54 | 显示全部楼层
用了贱客的方法连上了  非常感谢两位的热心帮助
回复 支持 反对

使用道具 举报

发表于 2014-8-29 12:39:34 | 显示全部楼层
呵呵~~~
终于等到高手出现了,
我也受教啦,感谢感谢
回复 支持 反对

使用道具 举报

发表于 2014-9-10 19:46:35 | 显示全部楼层
我在树梅派派上安装好mysql之后怎么都启动失败,大家有什么解决办法没有?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-20 12:50 , Processed in 0.041127 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表