Skip to content

Instantly share code, notes, and snippets.

@davydany
Last active November 21, 2019 16:17
Show Gist options
  • Save davydany/64c42f25bbdaa976a03cfe7c731faf5f to your computer and use it in GitHub Desktop.
Save davydany/64c42f25bbdaa976a03cfe7c731faf5f to your computer and use it in GitHub Desktop.
Setting up Django and MySQL Server on a Mac (2019)

Setting up Django and MySQL Server on a Mac (2019)

The following will show how to setup MySQL Server first, and setup Django to work with MySQL. This works with the Mac OS only.

Setup MySQL

Install MySQL with Homebrew

brew install mysql

Secure MySQL installation

Since MySQL gets setup without a proper root password, you need to secure it. Run the following utility to do so:

mysql_secure_installation

Launchd Start MySQL and Restart at Login

brew services start mysql

If you don't want/need a background service you can just run:

mysql.server start

Install Dependency for Python/Django

Install OpenSSL

brew install openssl

Now setup the path so that when pip or pipenv installs, it knows where OpenSSL is found.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

Install MySQL Library for Python

If you're using pip, run:

pip install mysqlclient

If you're using pipenv, run:

pipenv install mysqlclient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment