Configure the pythonmysql development environment in macOSX _ MySQL

Source: Internet
Author: User
Configure pythonmysql development environment python in macOSX

1. first download and install mysql ,:

Http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.19.tar.gz

Decompress:

Tar-xzvf mysql-5.6.19.tar.gz

Download gmock and use it to compile mysql:

Https://googlemock.googlecode.com/files/gmock-1.7.0.zip

Decompress the package to the specified directory.

unzip gmock-1.6.0.zip -d mysql-5.6.19/source_downloads

Go to the mysql source directory:

Cd myslq-5.6.19

Run:

Cmake.

Make

Make install

It may take more than 10 minutes to complete compilation and installation.

You can also use brew install mysql -- universal, but this command seems to be unavailable recently.


2. download and install mysql-python

Https://pypi.python.org/pypi/MySQL-python/1.2.5

After decompression, modify the site. cfg file:

Find this line:

# Mysql_config =/usr/local/bin/mysql_config

Remove the comment and change it:

Mysql_config =/usr/local/mysql/bin/mysql_config

Specify the path of the mysql_config file on your machine.

You can run the find/-name mysql_config command to confirm that if your mysql installation path is different from that in this article, the actual path prevails.

Then, execute:

Sudo python setup. py install


3. after the installation is successful, go to the python command line and enter

Import MySQLdb

An error occurs:

Library not loaded: libmysqlclient.18.dylib

This is because python cannot find the mysql path. run:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
After creating a soft link, you can solve this problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.