Issue
I have installed mariaDb (Mysql) on my raspberry pi .I am trying to connect my db using python from another machine over the same network but I receive the below error .
self.sock.connect(sockaddr)
ConnectionRefusedError: [Errno 61] Connection refused
The above exception was the direct cause of the following exception:
Both my machine and raspberry pi are over the same network . I can connect when I run the code on raspberry pi using localhost but running the same code on another machine gives above error .
import mysql.connector
if __name__ == '__main__':
db = mysql.connector.connect(host='192.168.0.108',user='admin123',password='abcd',database='cdr_mapping')
print(db)
Is there any config for mariadb which I need to set ?
Solution
Please open the config-file of mariadb under: /etc/mysql/my.cnf
Change the bind-address from 127.0.0.1 to 0.0.0.0
bind-address = 0.0.0.0
And restart mariadb.
On my second DB the file looks like this:
[client-server]
# Port or socket location where to connect
#port = 3306
socket = /run/mysqld/mysqld.sock
# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
I think I used following blog to solve the issue:
That worked for me :D
Answered By - solembum Answer Checked By - Katrina (WPSolving Volunteer)