Solved mariaDB/mysql not connected via python

100
11
NAS
DS412+
ssh into SynoNAS, sql.connector installed, MariaDB10 is running can be accessed by root query tables in command line.
but via python:
>> import mysql.connector
>> cnx = mysql.connector.connect(user='root', password='xxxxxx', host='127.0.0.1', database='mysql')
got following error:
Traceback (most recent call last):
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/mysql/connector/connection_cext.py", line 179, in _open_connection
self._cmysql.connect(**cnx_kwargs)
_mysql_connector.MySQLInterfaceError: Can't connect to MySQL server on '127.0.0.1' (111)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/mysql/connector/init.py", line 172, in connect
return CMySQLConnection(*args, **kwargs)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/mysql/connector/connection_cext.py", line 78, in init
self.connect(**kwargs)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/mysql/connector/abstracts.py", line 736, in connect
self._open_connection()
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/mysql/connector/connection_cext.py", line 182, in _open_connection
sqlstate=exc.sqlstate)
mysql.connector.errors.DatabaseError: 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)

I check also :
$ sudo netstat -plutn |grep -i sql
tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 14228/mysqld

seems mysql is running on 0.0.0.0 not 127.0.01 for loopback?
if so , how to set?


thanks for any thoughts.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Trending threads

Back
Top