Configure MySQL in Django Project(macOS)

项月亮
1 min readMar 7, 2020

Description:

Platform: macOS Catalina.

Virtual Environments: virtualenv

IDE: PyCharm

Steps:

  1. Install MySQL by HomeBrew
brew install mysql

2. Set your username and password of MySQL

mysqladmin -u root password "YOURPASSWORD"

Normally, if you install Python module “mysqlclient” immediately, following problem may occour

......
Running setup.py install for mysqlclient … error
......
clang: error: linker command failed with exit code 1 (use -v to see invocation)
......

So to avoid it, you should continue configuring according to step3 and step4.

3. Configure the OpenSSL

brew info openssl

Information given below such as this

export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

Add the information to ~/.bash_profile(if you use default bash) or ~/.zshrc(if you use zsh) and then “source” them.

4. Install “mysqlclient” through pip3.

pip3 install mysqlclient

That’s all done, start coding.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response