Reputation: 362
Hello , i am trying to connect to the database on my Hosting . I followed this tutorial :
https://www.thepythoncode.com/article/connect-to-a-remote-mysql-server-in-python
This is my code :
import pymysql.cursors
import pymysql
try:
connection = pymysql.connect(host='195.201.204.153',
user='turboweb_jobsuser',
password='TYcfvA*****',
db='turboweb_jobsdb_user',
)
print("Connected to:", connection.get_server_info())
except Exception as e:
print('connection failed')
print(e)
However, everytime I try to connect, this error occurs :
(2003, "Can't connect to MySQL server on '195.201.204.153' (timed out)")
The website address is :
assamjobsapp.turboweb.online
and doing a ping here,give me this IP : 195.201.204.153
I have created the Database , User and tables from the Hosting PHPMyadmin, but I dont know how to connect to it. Should I provide the database username/pass or the Cpanel username/pass for the connection
Please Help. Thanks
Upvotes: 0
Views: 981
Reputation: 108651
As comments have mentioned, many (most!) hosting providers put a firewall between their database servers and the public internet. Because cybercreeps. Attempts to do things that firewalls forbid usually results in the kind of timeout you got.
If you want to connect to your MySQL database from your laptop or some other machine that's outside the provider's firewall, you must ask them to adjust their firewall rule to allow your particular machine to connect. Once the firewall allows your machine to connect, use your database username / password to establish the connection.
Some providers have self-service user interfaces for this, often in their cpanels. Others require you to ask a customer support agent to do it.
Upvotes: 1