MySQL Python installation error on python 3 for mac

I have done so much research for connection databases on python and still canot figure it out. I have used mysql.connector, MySQLdb, and pymysql and none seem to work. For example

import pymysql
>>> db = pymysql.connect(host="127.0.0.1", user="root", passwd="", db="forge")
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pymysql/connections.py", line 669, in _connect
    sock.connect((self.host, self.port))
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    db = pymysql.connect(host="127.0.0.1", user="root", passwd="", db="forge")
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pymysql/__init__.py", line 93, in Connect
    return Connection(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pymysql/connections.py", line 510, in __init__
    self._connect()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pymysql/connections.py", line 679, in _connect
    raise OperationalError(2003, "Can't connect to MySQL server on %r (%s)" % (self.host, e.args[0]))
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (61)")  

When I type this code, I get this eror.. Please help me out


Source: python

Leave a Reply