0

I am using below codes in Python to connect a remote MySQL server:

>>> import MySQLdb
>>> MySQLdb.connect(user = 'root', passwd = 'XXXXX', db = 'AAA', host = 'XX.XXX.XXX.104')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/lib/python3.7/site-packages/MySQLdb/__init__.py", line 84, in Connect
    return Connection(*args, **kwargs)
  File "/anaconda3/lib/python3.7/site-packages/MySQLdb/connections.py", line 164, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'XX.XXX.XXX.104' (60)")
>>> 

Any idea what went wrong and any remediation will be very helpful. Thanks,

Bogaso
  • 2,838
  • 3
  • 24
  • 54
  • It is VERY unusual that a remote MySQL server would allow anybody to connect to it using `root` as the userid. HUGE SECURITY RISK. So ask the server admin to create you a userid that is allowed to connnect from your remote ip(domain) – RiggsFolly Mar 07 '19 at 17:04
  • 1
    Maybe you can check this answer. I hope it helps. [answer](https://stackoverflow.com/questions/16472175/operationalerror-operationalerror-2003-cant-connect-to-mysql-server-on-1) – Waleed S Khan Mar 07 '19 at 17:06
  • Or if you are trying to connect to your remote server provided by a hosting company, they also dont always allow remote connection. But if they do your control panel should provide you with a userid or a mechanism of creating a userid that will be allowed to connect from a remote domain – RiggsFolly Mar 07 '19 at 17:06
  • And there's another similar issue [cant connect to my sql](https://stackoverflow.com/questions/11121819/mysqldb-in-python-cant-connect-to-mysql-server-on-localhost) Maybe it's the port - have you checked on which one you can connect? Might help to specify in the connection – Erik Reder Mar 07 '19 at 17:08
  • Did you grant permissions for a remote root login? Usually you must GRANT and FLUSH to enable a remote connection. Also in your /etc/mysql/mysql.conf.d/mysqld.cnf. you may need to set the IP to 0.0.0.0. Check this one too https://stackoverflow.com/questions/6239131/how-to-grant-remote-access-permissions-to-mysql-server-for-user –  Mar 07 '19 at 18:23
  • Also you shouldn't have to worry about the port... if your mysql SERVICE IS RUNNING (because mysql is a SERVER, the port will already be open. All you need to specify is the correct IP –  Mar 07 '19 at 18:30

0 Answers0