0

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

5
  • i know that, but still i wanted to connect remotely, from my python programme. Is it possible ? Commented Dec 19, 2020 at 13:55
  • 1
    Get info from your hosting provider on how to do that. Commented Dec 19, 2020 at 13:56
  • okay, anyways do u have any refrence or tutorial. perhaps admin can only give me creds Commented Dec 19, 2020 at 13:57
  • Get in contact with your hosting provider, they can give information if they allow it, or that you are wasting time to try. Commented Dec 19, 2020 at 14:00
  • @Sainita: Can you undelete your recent question. I was about to post the answer. Commented Dec 22, 2020 at 16:28

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.