1

In google-colab, I tried this:

!pip install pymysql
import pymysql
cnx = {'host':'localhost','username':'root','pwd':'','db':'test'}
connection = pymysql.connect(cnx['host'], cnx['username'], cnx['pwd'], cnx['db'])
connection.close()

Error faced:

---------------------------------------------------------------------------
ConnectionRefusedError                    Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pymysql/connections.py in connect(self, sock)
    582                                 (self.host, self.port), self.connect_timeout,
--> 583                                 **kwargs)
    584                             break

5 frames
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

OperationalError                          Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pymysql/connections.py in connect(self, sock)
    628                 exc.traceback = traceback.format_exc()
    629                 if DEBUG: print(exc.traceback)
--> 630                 raise exc
    631 
    632             # If e is neither DatabaseError or IOError, It's a bug.

OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)")

Tried the suggestion of 127.0.0.1, but no luck and then seeing this, tried:

connection = pymysql.connect(cnx['host'], cnx['username'], cnx['pwd'], cnx['db'],port=3306)

Still same connection refused. Is it even possible to connect to local database from google-colab? If so, what is the error else what option do I have ?

Database details(running from XAMPP):

MySQL Version                 : 10.1.13-MariaDB
Host                          : localhost
User                          : root
Port                          : 3306
Server Default Charset        : latin1

Status of my.ini file: bind-address="127.0.0.1" and password is commented out in the file # password = your_password. In SQLYog databse is running.

Rex5
  • 771
  • 9
  • 23
  • Can I get the endpoint(like it is available in aws db) of this mysql database somehow ? – Rex5 Aug 02 '19 at 07:01

0 Answers0