Python connection MySQL

Source: Internet
Author: User

Environment: Mac,pycharm Editor

1. Use Brew to install MySQL under Mac

Brew Install MySQL

B. View installation Information

Brew Info MySQL

2. Download mysql-python-1.2.3

When the download is complete, go to the mysql-python-1.2.3 folder and execute the following command

Python setup.py Build

You encounter a problem like this: Mysql_config not find similar errors

The setup_posix.py should be modified at this time, after the MySQL installation is complete,

Find the location of the Mysql_config file

sudo find  /-name mysql_config

Mysql_config default location/usr/local/bin/mysql_config, so modify to Mysql_config.path = "/usr/local/bin/mysql_config"

And then re-execute

Python setup.py Build
Python setup.py instal

3. Return to the Pycharm editor

After installing the Mysql-python package, let us import mysqldb, there is an error, the last line of error is written reason:image not found.

Workaround in Terminal input:

sudo ln-s/usr/local/cellar/mysql/5.7.10/lib/libmysqlclient.20.dylib/usr/lib/libmysqlclient.20.dylib

Python connection MySQL

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.