How to Install mysql.connector?

To connect the python application with the MySQL database, we must import the mysql.connector module in the program. The mysql.connector is not a built-in module that comes with the python installation. We need to install it to get it working.

Run the following command to install it using pip installer.

File name : index.py

python -m pip install mysql-connector

Download and install "MySQL Connector":

File name : index.py

C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>python -m pip install mysql-connector-python

Step

File name : index.py

Download MySql Connector
Download
Download MySQl
  • 2. Extract the archived file
  • Open the terminal (CMD for windows) and change the present working directory to the source code directory.
    cd mysql-connector-python-8.0.13/
  • Run the file named setup.py with python.
    python setup.py build
  • Run the following command to install the mysql-connector.
    python setup.py install

  • Test MySQL Connector

    To test if the installation was successful, or if you already have "MySQL Connector" installed, create a Python page with the following content:

    File name : demo_mysql_test.py

    import mysql.connector

    If the above code was executed with no errors, "MySQL Connector" is installed and ready to be used.





    Previous Next


    Trending Tutorials




    Review & Rating

    0.0 / 5

    0 Review

    5
    (0)

    4
    (0)

    3
    (0)

    2
    (0)

    1
    (0)

    Write Review Here