MySQLDB模块安装--Mac系统

一、首先在系统中安装mysql

安装包路径

http://www.mysql.com/downloads/

MySQL Community Edition

(GPL)
Community (GPL) Downloads

  • MySQL Community Server (GPL)
    (Current Generally Available Release: 5.7.16)MySQL Community Server is the world‘s most popular open source database.DOWNLOAD

选择最下面一个下载

下载后直接点击,进行安即可

安装后

wulilideMacBook-Pro:bin root# mysql --version

mysql command not foud

wulilideMacBook-Pro:bin root# ln -fs /usr/local/mysql/bin/mysql mysql

wulilideMacBook-Pro:bin root# /usr/local/mysql/support-files/mysql.server start

Starting MySQL

. SUCCESS!

wulilideMacBook-Pro:bin root# /usr/local/mysql/support-files/mysql.server sop

Usage: mysql.server  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]

wulilideMacBook-Pro:bin root# /usr/local/mysql/support-files/mysql.server stop

Shutting down MySQL

.. SUCCESS!

2、安装mysql-python

使用pip安装是没有办法修改安装包中的文件的,,是会一直报错的

wulilideMacBook-Pro:~ root# pip install MySQL-python

Collecting MySQL-python

Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by ‘ReadTimeoutError("HTTPSConnectionPool(host=‘pypi.python.org‘, port=443): Read timed out. (read timeout=15)",)‘: /simple/mysql-python/

Using cached MySQL-python-1.2.5.zip

Complete output from command python setup.py egg_info:

sh: mysql_config: command not found

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/private/tmp/pip-build-8VXXdd/MySQL-python/setup.py", line 17, in <module>

metadata, options = get_config()

File "setup_posix.py", line 43, in get_config

libs = mysql_config("libs_r")

File "setup_posix.py", line 25, in mysql_config

raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-8VXXdd/MySQL-python/

只好选择源码包安装

下载源码包

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

选择源码包下载,解压,

修改解压后的配置文件

wulilideMacBook-Pro:MySQL-python-1.2.5 root# pwd

/Users/wulili/Downloads/MySQL-python-1.2.5

wulilideMacBook-Pro:MySQL-python-1.2.5 root# ls -l

total 336

[email protected]  1 wulili  staff  18092 Oct  8  2012 GPL-2.0

[email protected]  1 wulili  staff   5687 Jan  1  2013 HISTORY

[email protected]  1 wulili  staff   6636 Oct  8  2012 INSTALL

[email protected]  1 wulili  staff    309 Jan  2  2014 MANIFEST.in

[email protected]  6 wulili  staff    204 Nov  4 18:34 MySQL_python.egg-info

drwxr-xr-x   9 wulili  staff    306 Nov  4 18:34 MySQLdb

[email protected]  1 wulili  staff   1689 Jan  2  2014 PKG-INFO

[email protected]  1 wulili  staff   1266 Oct  4  2012 README.md

[email protected]  1 wulili  staff  84709 Jan  2  2014 _mysql.c

[email protected]  1 wulili  staff   2352 Oct  8  2012 _mysql_exceptions.py

drwxr-xr-x  12 wulili  staff    408 Nov  4 18:34 doc

[email protected]  1 wulili  staff   2039 Jan  2  2014 metadata.cfg

[email protected]  1 wulili  staff   3203 Oct  8  2012 pymemcompat.h

[email protected]  1 wulili  staff    398 Jan  2  2014 setup.cfg

[email protected]  1 wulili  staff    609 Jan  2  2014 setup.py

[email protected]  1 wulili  staff   1088 Oct  8  2012 setup_common.py

[email protected]  1 wulili  staff   3392 Jan  2  2014 setup_posix.py

[email protected]  1 wulili  staff   1334 Oct  8  2012 setup_windows.py

[email protected]  1 wulili  staff    665 Oct  8  2012 site.cfg

drwxr-xr-x   8 wulili  staff    272 Nov  4 18:34 tests

wulilideMacBook-Pro:MySQL-python-1.2.5 root# vim setup_posix.py

wulilideMacBook-Pro:MySQL-python-1.2.5 root# vim setup_posix.py

raise EnvironmentError("%s not found" % (mysql_config.path,))

return data

mysql_config.path = "/usr/local/mysql/bin/mysql_config"

def get_config():

from setup_common import get_metadata_and_options, enabled, create_release_file

wulilideMacBook-Pro:MySQL-python-1.2.5 root# vim site.cfg

# The path to mysql_config.

# Only use this if mysql_config is not on your PATH, or you have some weird

# setup that requires it.

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

# http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip

# Windows connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build.

connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2

修改好后安装即可

wulilideMacBook-Pro:MySQL-python-1.2.5 root# python setup.py install

wulilideMacBook-Pro:MySQL-python-1.2.5 root# python

Python 2.7.10 (default, Oct 23 2015, 19:19:21)

[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import MySQLdb

/Library/Python/2.7/site-packages/MySQL_python-1.2.5-py2.7-macosx-10.11-intel.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Python/2.7/site-packages/MySQL_python-1.2.5-py2.7-macosx-10.11-intel.egg/_mysql.pyc, but /Users/wulili/Downloads/MySQL-python-1.2.5 is being added to sys.path

>>>

能导入成功说明安装好了

时间: 2024-10-10 03:39:16

MySQLDB模块安装--Mac系统的相关文章

Mac MySQLdb模块安装,可算解决了

转载:http://blog.csdn.net/janronehoo/article/details/25207825 短评:这篇文章感觉是比较全面解决Mac MySQLdb模块安装问题的文章了,特别转载一下. 连错误都解决了...爽,话说困扰我半个月MySQLdb,差点就要放弃了 Python 2.7.3. MySQL-python包中,因此无论下载还是在pip中search,都应该是搜寻MySQL-python. 下载MySQLdb MySQL-python-1.2.4b4.tar,下载后解

制作U盘安装MAC系统

利用Terminal.制作U盘安装MAC系统 ================ 1.准备: 一个U盘,已经格式化为[Mac OS Extended (Journaled)]/[Mac OS 扩展(日志式)]: 一个已经下载好的OS X Yosemite系统文件: 一台MAC电脑: 2.打开Terminal: 英文版 sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --vol

Python的MySQLdb模块安装

在配置Django时,选择的是mysql数据库,要安装MySQLdb模块,不过安装过程中,遇到了很多errors,记录一下. 系统:ubuntu 11.10 mysql:直接apt-get安装的,version:5.1.62 到官方下载MySQL for Python 然后解压,打开README: 里面有安装过程: $ tar xfz MySQL-python-1.2.1.tar.gz $ cd MySQL-python-1.2.1 $ # edit site.cfg if necessary

Python安装MySQLdb模块安装

下载源码:http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.4b4/MySQL-python-1.2.4b4.tar.gz/download mv download MySQL-python-1.2.4b4.tar.gz tar -zxvf MySQL-python-1.2.4b4.tar.gz cd MySQL-python-1.2.4b4 python setup.py build 报错:mysq

U盘安装MAC系统

同事的Mac笔记本之前系统换成Windows,最新想改回Mac系统,下面详细介绍下操作步骤:1.利用其他同事的MAC笔记本制作U盘启动,打开AppStore下载macOS High Sierra系统程序.2.在Mac电脑插入U盘,打开"应用程序->实用工具->磁盘工具",点击"抹掉",选择"Mac OS扩展(日志式)"."GUID分区图",点击"抹掉"3.制作启动盘,打开终端 输入sudo /A

【学习笔记】虚拟机安装Mac系统

参考了这篇装的虚拟机 http://jingyan.baidu.com/article/ff411625b9011212e48237b4.html 系统的话可以到远景去找找 安装用工具: http://pan.baidu.com/s/1bnvuvQf unlocker203 :上文有介绍让Vmware可以创建MAC OS X的 Vmware_Tools_for_Mac.iso: 创建共享文件的 darwin710.iso:使虚拟机全屏不花屏 darwin.iso:忘了有什么用了

python操作mysql(一)MySQLdb模块安装和数据库基本操作

1.ubuntu环境下安装python-MySQLdb sudo apt-get install build-essential python-dev libmysqlclient-dev sudo apt-get install python-MySQLdb 2.或者PIP安装 pip install mysql-python 3.安装好之后导入模块 import MySQLdb 4.登入数据库后查看数据库 mysql> show databases;+--------------------

Clover 安装 Mac 系统更新 (原版黑苹果)

关于使用原版镜像(即 .dmg )安装黑苹果的升级,笔者写写自身经验吧. 在Clover启动的界面中与Mac OS有关的启动菜单有以下这些: Boot FileVault Prebooter from Preboot Boot macOS Install Prebooter from Preboot Boot macOS from Mac Boot Recovery from Recovery 其它什么的笔者此处不作讨论 正常启动Mac OS 笔者从 Boot macOS from Mac 启动

django安装--mac系统

直接命令安装完全不管用,mac没什么反应 下载django,地址https://www.djangoproject.com/download/ tar xzvf Django-1.5.1.tar.gz cd Django-1.5.1 sudo python setup.py install 在pythone下,import django,如果没有错误,就说明安装成功了