How do I get other users to access my Mysql database with Python?

Asked

Viewed 27 times

-1

I am making a program with the mysql-Connector-python library and I wanted other users to be able to access it, because when I start the program on another machine appears the following error:

Traceback (most recent call last):
File "C:/Users/Dirsoo/PycharmProjects/Sistema/Sistema.py", line 11, in <module>
database='sistema_cadastro_produtos'
File "C:\Program Files\Python37-32\lib\site-packages\mysql\connector\__init__.py", line 265, in connect
return MySQLConnection(*args, **kwargs)
File "C:\Program Files\Python37-32\lib\site-packages\mysql\connector\connection.py", line 104, in __init__
self.connect(**kwargs)
File "C:\Program Files\Python37-32\lib\site-packages\mysql\connector\abstracts.py", line 966, in connect
self._open_connection()
File "C:\Program Files\Python37-32\lib\site-packages\mysql\connector\connection.py", line 288, in _open_connection
self._socket.open_connection()
File "C:\Program Files\Python37-32\lib\site-packages\mysql\connector\network.py", line 611, in open_connection
errno=2003, values=(self.get_address(), _strioerror(err)))
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (10061 Nenhuma conexão pôde ser feita porque a máquina de destino as recusou ativamente)

How can I do that?

1 answer

1


The issue here is not exactly Python’s.

The problem is that access is being made to localhost:3306. Localhost is the address of loopback, in other words, it is the machine itself.

I believe in the program C:/Users/Dirsoo/PycharmProjects/Sistema/Sistema.py line 11, you have the connection string.

Altere of loopback to the IP address of the host where the database or FQDN (full Qualified Domain name) is located - e.g.: 192.168.1.1 or url.do.banco.com.br

I hope the tip helps.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.