0
votes

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.

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.

my mysql server is at 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)

The thing is that i used all the correct infos regarding host,database,user,password in my 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.

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:

[client-server]

!includedir /etc/mysql/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

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...

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'%";

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.

I've been trying to solve this for days i really wish someone can help me on this, thank you.

1

1 Answers

0
votes

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. 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.