Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install MySQL Connector on Windows,MacOs,Linux,Unix and Ubuntu

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In this article, we will show you how to install MySQL Connector Python on Windows,MacOs,Linux,Unix and Ubuntu using pip and vis source code.

To connect to the MySQL server from Python, you need a database driver (module). MySQL Connector Python is the official driver supported by Oracle to connect to MySQL through python.

This article is part of our Python MySQL tutorial series.

After this article, solve our free Python database exercise to practice and master database skills in Python.

Directory->

You need root or administrator privileges to perform the installation process.

Python must be installed on your computer.

Note:-MySQL Connector Python requires that python be in the PATH of the system. If Python is not found, the installation will fail.

On Unix and Unix-like systems, Python is usually located in the directory included in the default PATH settings.

"on Windows, if Python does not exist in the system's PATH, manually add the directory that contains python.exe."

Platform: 64-bit Windows,Windows 10 Magi Windows 7 Magi Windows 8 Magi Windows Vista,Windows XP,Linux,Ubuntu Linux,Debian Linux,SUSE Linux,Red Hat Linux,Fedora,MacOs.

Python version: Python 2 and 3

MySQL version: http://www.d9vt.com

Different ways to install MySQL Connector Python

There are several ways to install Oracle's MySQL Connector Python on your computer. Here are several ways.

Use the pip command to install MySQL Connector Python

Install MySQL connector python from source code (through ZIP or TAR files)

Use built-in distribution packages created in native packaging format for a given platform. For example, Linux's RPM package or Windows's MSI installer.

Python MySQL Connector version

Please refer to the MySQL Connector python version table below. You need to install a module that is compatible with your version of python.

Connector / Python version MySQL server

The Python version supported by the version

8.0 (a continuation of 2.2) 8.0 Magic 5.7, 5.6, 5.6, 5.53.6, 3.4, 3.72.25.7, 5.6, 5.73.25.7, 5.6, 5.73.15.7, 5.6, 5.3.5, 3.4, 2.7, 2.62.05.7, 5.63.05.7, 5.63.5, 3.4, 2.7, 2.61.25.7, 5.6, 5.5, 5.5 (5.1, 5.04.1) 3.43.3, 3.2, 3.1, 2.72.6.

Show 1 to 5 of the 5 entries

Big!

Pip command to install MySQL Connector python

Using pip to install any module in python is always accessible and direct. MySQL Connector Python can be found on pypi.org, so you can install it using the pip command.

Using the pip command, you can install MySQL Connector python, including Windows,MacOs,Linux,Unix and Ubuntu, on any operating system platform.

Pip install mysql-connector-python

If you encounter any problems with the installation, please mention the version of the module and try to install it again. Please refer to the table above to install the correct version.

Pip install mysql-connector-python = = 8.0.11

If you are facing a pip installation failure error and display "connection error: [SSL:CERTIFICATE_VERIFY_FAILED] Certificate validation failed (_ ssl.c:598)". You can resolve this error.

You can ignore SSL errors by setting pypi.org and files.pythonhosted.org as trusted hosts. Try to install MySQL Connector Python according to the pip command.

Python-m pip install-trusted-host pypi.org-trusted-host files.pythonhosted.org-trusted-host pypi.python.org mysql-connector-python

Verify MySQL Connector Python installation

After running the pip command, you should receive the following message

Collect mysql-connector-python

Download the package.

The requirements have been met: the setup tool in D:python\ python37-32\ lib\ site-packages.

Install the collected package: mysql-connector-python

Mysql-connector-python-8.0.13 installed successfully

Verify the MySQL Connector Python installation by connecting to the MySQL using MySQL Connector Python.

Check out our Python database programming exercises to master the database programming techniques in Python.

If you cannot install using pip, you can use the following methods to install.

Download and install MySQL Connector Python on Windows

There are two ways to install MySQL Connector Python on Windows.

Distribute the installation using source code (platform-independent and architecture-independent ZIP archives)

Install using Built Distribution, the MSI installer

Install MySQL Connector Python on Windows using source code distribution:-

Follow the instructions below to download the platform independent ZIP. Download the Python window of the MySQL connection from here

Download MySQL Connector python for Windows

Abobe URL automatically opens the latest version of MySQL Connector Python.

If you want to use an older version that is compatible with your python version, select the find previous GA version option, which you can find on the right.

If you want to check which version of MySQL Connector Python is compatible with your python version, refer to the table above.

I am downloading 2.1.7 because I am using Python 3.5. Select an independent platform from the drop-down list

Click the download button to download the ZIP file on your machine. After clicking download, you will see the following screen. Click "No, Thank you" to start the download option.

Start downloading the MySQL Connector python zip file for windows

Note: if you want to download the latest version, 8.0.1, select the "find the latest GA version" option, which you can find on the right.

After the download is complete, follow these steps to install:-

Using 7Zip or other tools that can read .zip files, extract or extract the Zip archive in the target installation directory (for example, C:\ mysql-connector\).

Launch the console window and change the location to the folder where you unzipped the Zip archive:

C:\ > cd C:\ mysql-connector\

In the MySQL Connector Python folder, use the following command to perform the installation:

C:\ > python setup.py install

You should get the following screen after this command.

Python MySQL Connector python installation for Windows

Verify MySQL Connector / Python installation on Windows

To verify the MySQL connection, install Python, and make sure it works, you can connect to the MySQL database server without problems. To verify the installation, use the following steps:

On Windows, the default MySQL Connector Python installation location is C:\ Python. Version\ Lib\ sitepackages\. Here Python.version is the Python version used to install connectors.

Type import mysql connector using import mysql. Connector. If the execution is successful, it means that the installation completed successfully.

In addition, you can check that the MySQL Connector Python installation is working and that you can connect to the MySQL server by connecting to MySQL using MySQL Connector Python.

Download and install MySQL Connector Python on Linux

There are two ways to install MySQL Connector Python on Unix and Unix-like systems such as Linux,Solaris,macOS and FreeBSD.

Use source code to distribute the installation (platform independent (architecture independent), TAR file)

You can use the Built Distribution for Example RPM file for installation.

Install MySQL Connector Python on Linux using source code distribution. Follow the instructions below to download the MySQL Connector python platform standalone TAR (tar.gz) file.

Download the Linux of the MySQL-connected Python from here and it will open the screen below.

Download MySQL Connector python for Linux

It opens the latest version of the MySQL connector python. If you want to install a version other than 8.0.1, select the Previous GA version from the right. You can refer to the table above to check which version is compatible with your python version.

Select a platform-independent TAR from the Select operating system drop-down list. I am downloading 2.1.7 because I am using Python 3.5

MySQL Connector python platform independent of Linux's tar

Select the TAR archive file and click the download button. You should see the following screen and click to start the download.

MySQL Connector python starts downloading for Linux

After the download is complete, follow these steps to install:-

Extract the downloaded tar.gz file. Use the following command to extract.

Shell > tar xzf mysql-connector-python-VERSION.tar.gz

Change to the directory where the tar file was extracted

Shell > cd mysql-connector-python-VERSION

Execute shell > sudo python setup. The py install command installs the MySQL connector python on Linux.

To see all the options and commands supported by setup.py, use the python setup.py-- help command

Verify MySQL Connector Python installation on Linux

On Unix-like systems, the default Connector / Python installation location is / prefix/python.VERSION/site-packages/, where prefix is the location where Python is installed and VERSION is the Python version.

Type imported MySQL. Connector and execute the program. If the execution is successful, it means that the installation completed successfully.

In addition, you can check that the MySQL Connector Python installation is working and that you can connect to the MySQL server by connecting to MySQL using MySQL Connector Python.

Download and install MySQL Connector Python on MacOs

You can install MySQL Connector Python on macOS using a disk image.

Download MySQL from here to connect python to MacOS

Please refer to the table above to check which version is compatible with your python version

Download the mysql-connector-python-8.0.11-macos10.13.dmg file. It is a schema-independent DMG file.

. Install the downloaded MySQL Connector Python by opening it and double-clicking the generated .pkg file.

Verify MySQL Connector Python installation on MacO

Check that the MySQL Connector Python installation is working and that you can connect to the MySQL Server by connecting to the MySQL using MySQL Connector Python.

Install MySQL Connector Python on Ubuntu

Use the following command to install the MySQL connector Python on Ubuntu.

Sudo apt-get install mysql-connector-python

Run the following command after that.

Pip install mysql-connector-python

If the command fails in Python3, you can replace pip with pip3. If the above method doesn't work, you can still install it on Ubuntu using the source code.

Download MySQL's Ubuntu for connecting pythons from here.

Select the operating system Ubuntu Linux from the drop-down list.

I chose Ubuntu-Linux 16.04 (independent of architecture).

You should get two entries for DEB Package python from MySQL Connector Python (for python 2 and Python 3). Install MySQL Connector python on Ubuntu

Download the listed DEB package and install it using the following command.

First, extract the DEB file, and then install it.

Run the following command after that.

Sudo apt-get install-f

Sudo dpkg-I / path_to_downloaded_deb_file

You have now finished installing MySQL Connector Python on Ubuntu.

More: http://www.d9vt.com

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report