[英]2003: Can't connect to MySQL server on '192.168.0.14:3306' (111 Connection refused)
I im trying to insert data read from a raspberry pi into a database hosted on another raspberry pi, i used mysql as database and my code is writtin in python on the "client" pi, this operation is all done on local network.我试图将从树莓派读取的数据插入到另一个树莓派上托管的数据库中,我使用 mysql 作为数据库,我的代码在“客户端”pi 上用 python 编写,此操作全部在本地网络上完成。
i did all the config in order to connect as "RaspberryPi" user that i created and granted all permissions on the specific database and table on ip: 192.168.0.20 which is the client pi, i created and granted that user from root user of mysql which i granted all permission just before in case it needed to.我完成了所有配置,以便以我创建的“RaspberryPi”用户身份进行连接,并授予了对特定数据库和 ip 表的所有权限:192.168.0.20,即客户端 pi,我从 mysql 的 root 用户创建并授予了该用户我之前授予了所有许可,以防万一。
my mysql server is at 192.168.0.14.我的 mysql 服务器在 192.168.0.14。 when i run my python program it shows this error: Failed to insert record into HumiditySensor table 2003: Can't connect to MySQL server on '192.168.0.14:3306' (111 Connection refused)
当我运行 python 程序时,它显示此错误:无法将记录插入 HumiditySensor 表 2003:无法连接到 MySQL 服务器上的“192.168.0.14:3306”(111 连接被拒绝)
The thing is that i used all the correct infos regarding host,database,user,password in my mysql.connector.connect()问题是我在 mysql.connector.connect() 中使用了有关主机、数据库、用户、密码的所有正确信息
I veryfied if the server was using the right port to communicate and it was port 3306 which is what i expected.如果服务器使用正确的端口进行通信,我非常确定它是端口 3306,这正是我所期望的。
I saw online that the problem might be caused by tcp/ip skipping, i looked at my my.cnf file and all i have is:我在网上看到问题可能是由 tcp/ip 跳过引起的,我查看了 my.cnf 文件,我只有:
[client-server] [客户端服务器]
!includedir /etc/mysql/conf.d/ !includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/ !includedir /etc/mysql/mariadb.conf.d/
The rest is commented.其余有评论。 i couldnt see bind-address nor tcp/ip skipping so i dont believe it's because of an ip binding or wtv
我看不到绑定地址或 tcp/ip 跳过,所以我不相信这是因为 ip 绑定或 wtv
I also looked if my mysql server was running by looking if the mysql.sock file was in /var/run/mysqld folder and it was...我还通过查看 mysql.sock 文件是否在 /var/run/mysqld 文件夹中来查看我的 mysql 服务器是否正在运行,它是...
i did this command to see if the grant permission worked on my RaspberrPi user by typing: SELECT * from information_schema.user_privileges where grantee like "'RaspberryPi'%";我执行此命令以查看授予权限是否对我的 RaspberrPi 用户有效,方法是键入:SELECT * from information_schema.user_privileges where grantee like "'RaspberryPi'%";
in mysql shell on host raspberry pi and it showed me in the "IS_GRANTABLE" section that everything was at "YES" instead of "NO" which means that this user has all permissions.在主机 raspberry pi 上的 mysql shell 中,它在“IS_GRANTABLE”部分向我展示了一切都在“是”而不是“否”,这意味着该用户拥有所有权限。
I've been trying to solve this for days i really wish someone can help me on this, thank you.这几天我一直在努力解决这个问题,我真的希望有人能帮我解决这个问题,谢谢。
thanks for the answer!谢谢你的回答! But i found it!
但是我找到了! if anybody encounters the same error i had, to solve that problem, you need to modify the /etc/mysql/mariadb.conf.d/50-server.cnf file since today when you install mysql, it install mariadb instead and i guess the config files are different.
如果有人遇到我遇到的相同错误,要解决该问题,您需要修改 /etc/mysql/mariadb.conf.d/50-server.cnf 文件,因为今天安装 mysql 时,它会安装 mariadb,我猜配置文件不同。 then once you get into 50-server.cnf you just need to comment "bind-address = 127.0.0.1" and it will now listen to other IPs requests.
然后,一旦您进入 50-server.cnf,您只需要注释“bind-address = 127.0.0.1”,它现在将侦听其他 IP 请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.