How to install MySQL for Python on Mac

Installing MySQL in Mac and establishing connectivity with Python is simple. Follow the steps in sequence to make a successful connection for MySQL and Python.

Prerequisites to Install MySQL

  • Python shall be available
  • 500 MB Space for MySQL
  • MySQL Installer Package for Mac
  • Python SQL Connector for Mac

Install MySQL on Mac for Python

  1. Go to You shall see the list of packages available for Mac.
Download MySQL TAR file from website
  1. Choose Download for DMG archive. (The first option from the top.)
  2. You will be asked to Sign up. But there is also an option, No thanks, just start my download. Click that link.
Login or signup with your credentials
  1. Once downloaded, you will see the package file in the downloads folder.
Double click MySQL PKG  file to start installation
  1. Double-click the package file to start MySQL installation. The below pop up asking for permission appears.
Allow the installation when security question appears
  1. Choose Allow to proceed. The welcome screen shall be shown.
continue with MySQL installation
  1. Say Continue. The license agreement screen is shown.
Accept the license
  1. Click Continue. The agreement pop up shall appear.
read and accept the license
  1. Choose Agree. The next screen appears to choose Installation type.
customize the MySQL installation on Mac
  1. Click Install. The installation process starts.
  2. When it finishes, it asks to set up password encryption.
Setup password for MySQL on Mac
  1. Keep the selected option to continue. Choose Next.
  2. Set the password for the root user.
setup root password for MySQL
  1. Click Finish. The completion message shall be shown and click Close to complete the installation.
Finish the MySQL installation

also read:

Start MySQL on mac

  1. Open System Preferences. You shall see the MySQL icon.
Find MySQL in System Preferences
  1. Click to start the server.
Start MySQL service from preferences

Install pip on Mac

  1. Open terminal window and type the command

curl -o

  1. Once downloaded, enter the command below:


  1. Wait till installation gets completed successfully.
install PIP in Mac from terminal

Download and Install Python Connector

  1. Go to the
Download MySQL connector for Mac
  1. Once downloaded successfully, go to the terminal window and enter the command.

pip install mysql-connector-python

Import MySQL Connector in Python

To connect to MySQL server using Python, go to Python in terminal and use the connect() method to establish connectivity.

import mysql.connector
con = mysql.connector.connect(user='rbm', password='[email protected]', host='', database='customer')

Scroll to Top