Python Programming Tutorial – 48: Install MySql Connector for Python




In this tutorial we’ll begin our discussion on using python to interact with MySql databases. We’ll download and install the MySql connector for python and …

Original source


21 responses to “Python Programming Tutorial – 48: Install MySql Connector for Python”

  1. Hi! I am using python 2.7 and I installed the SQL connector for the same. But when I run the command
    conn=mysql.connector.connect(user='root',password='varun',host='localhost')
    I am getting the following error message. could you please help me!?
    Error: Can't connect to MySQL server on 'localhost:3306' (10061 No connection could be made because the target machine actively refused it)

  2. what should I do next if I found this error when I try to import mysql.connector?
    >>> import mysql.connector

    Traceback (most recent call last):
    File "<pyshell#0>", line 1, in <module>
    import mysql.connector
    ImportError: No module named mysql.connector

  3. hi, i have installed mysql connector but i can only import mysql.connector for python 2.7 which comes with mac, though i have python3.5, but in python3.5 i get an error ImportError: no module named 'mysql'… please suggest for python3.5… many thanks

  4. when i try to connect m getting the following errors 

    >>> conn=mysql.connector.connect(user='root',password='',host='localhost')
    Traceback (most recent call last):
      File "C:Python34libsite-packagesmysqlconnectornetwork.py", line 467, in open_connection
        self.sock.connect(sockaddr)
    ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<pyshell#24>", line 1, in <module>
        conn=mysql.connector.connect(user='root',password='',host='localhost')
      File "C:Python34libsite-packagesmysqlconnector__init__.py", line 159, in connect
        return MySQLConnection(*args, **kwargs)
      File "C:Python34libsite-packagesmysqlconnectorconnection.py", line 129, in _init_
        self.connect(**kwargs)
      File "C:Python34libsite-packagesmysqlconnectorconnection.py", line 454, in connect
        self._open_connection()
      File "C:Python34libsite-packagesmysqlconnectorconnection.py", line 417, in _open_connection
        self._socket.open_connection()
      File "C:Python34libsite-packagesmysqlconnectornetwork.py", line 470, in open_connection
        errno=2003, values=(self.get_address(), _strioerror(err)))
    mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (10061 No connection could be made because the target machine actively refused it)

Leave a Reply