I have been trying to deploy a Streamlit app on Heroku and connect to a MySQL database. With a consistent error: InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (111 Connection refused)
Generally, I connect to the database the following way:
mysql.connector.connect(host="localhost",user="****",
password="****",
database="**********"
)
- I've looked in my MySQL config file (my.ini file in my case) for the
bind-address = 127.0.0.1
, the file exists but the line isn't there. - I have tried restarting MySQL.
- Grant privileges:
Varying in different scopes, trying on database or just generally.
GRANT ALL PRIVILEGES ON <databasename>.* TO '<username>'@'localhost' IDENTIFIED BY '<password>';
- Creating a new user:
Again, varying in different scopes.
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
- New admin account:
giving VERY wide scope
mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> WITH GRANT OPTION;
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
-> WITH GRANT OPTION
- Considered Windows Firewall
https://www.opendental.com/manual/port3306.html
I think the issue is something to do with the fact that there are no active connections (but I am unsure what to do):
C:\Users\madel>netstat -tnp
Active Connections
Proto Local Address Foreign Address State Offload State
Further:
C:\Users\madel>netstat -tna | findstr LISTEN
-tna | findstr LISTEN
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:5040 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:6646 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:7680 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:33060 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:49664 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:49665 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:49666 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:49667 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:49668 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:49674 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:53050 0.0.0.0:0 LISTENING InHost
TCP 0.0.0.0:57621 0.0.0.0:0 LISTENING InHost
TCP 127.0.0.1:28385 0.0.0.0:0 LISTENING InHost
TCP 127.0.0.1:28390 0.0.0.0:0 LISTENING InHost
TCP 127.0.0.1:49350 0.0.0.0:0 LISTENING InHost
TCP 127.0.0.1:49351 0.0.0.0:0 LISTENING InHost
TCP 192.168.0.6:139 0.0.0.0:0 LISTENING InHost
TCP 192.168.56.1:139 0.0.0.0:0 LISTENING InHost
TCP [::]:135 [::]:0 LISTENING InHost
TCP [::]:445 [::]:0 LISTENING InHost
TCP [::]:3306 [::]:0 LISTENING InHost
TCP [::]:7680 [::]:0 LISTENING InHost
TCP [::]:33060 [::]:0 LISTENING InHost
TCP [::]:49664 [::]:0 LISTENING InHost
TCP [::]:49665 [::]:0 LISTENING InHost
TCP [::]:49666 [::]:0 LISTENING InHost
TCP [::]:49667 [::]:0 LISTENING InHost
TCP [::]:49668 [::]:0 LISTENING InHost
TCP [::]:49674 [::]:0 LISTENING InHost
TCP [::1]:49671 [::]:0 LISTENING InHost
Next step (I used my MySQL password here?? unsure)
C:\Users\madel>nc -v 127.0.0.1 3306
LAPTOP-2KQID6GI [127.0.0.1] 3306 (?) open
J
→27
♂9aN↑
☻ ▀§ "K\↓sK8e¶▼>w caching_sha2_password ******
! ☺ ä♦#08S01Got packets out of order
HALP!