mac os 上安装mysqldb,EnvironmentError: mysql
$ sudo python setup.py clean $ sudo python setup.py build $ sudo python setup.py install $ export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH $python import MySQLdb /Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-m
$ sudo python setup.py clean
$ sudo python setup.py build
$ sudo python setup.py install
$ export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
$python
>>> import MySQLdb
/Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg/_mysql.pyc, but /Users/***/Downloads/MySQL-python-1.2.3
is being added to sys.path
>>> conn=MySQLdb.connect(host="localhost",user="root",passwd="root",db="mysql")
>>> cursor =conn.cursor()
>>> sql ="select * from user"
>>> cursor.execute(sql)
7L
>>> row=cursor.fetchone()
>>> print row
('localhost', 'root', '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '', '', '', '', 0L, 0L, 0L, 0L, '', '')
能够读取mysql.user表的信息了,说明已经mysqldb已经安装成功。
或者修改bash_profile文件
PATH="/usr/local/mysql/bin:${PATH}" export PATH export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/ export VERSIONER_PYTHON_PREFER_64_BIT=yes export VERSIONER_PYTHON_PREFER_32_BIT=no
参考:http://*.com/questions/1465846/install-mysqldb-on-snow-leopard/6537345#6537345
推荐阅读
-
mac os 上安装mysqldb,EnvironmentError: mysql
-
Mac上安装MySQL过程分享_MySQL
-
Mac上安装MySQL过程分享_MySQL
-
轻松掌握在 Mac OS X中安装MySQL_MySQL
-
在Mac OS上搭建Nginx+PHP+MySQL开发环境的教程,_PHP教程
-
Mac OS X Mavericks or Yosemite 安装Nginx、PHP、Mysql、
-
教你如何在Mac上安装mysql数据库
-
在Mac OS上编译安装Nginx+PHP+MariaDB开发环境的教程,nginxmariadb_PHP教程
-
mac os nginx php mysql mac os mysql 启动 mac os 10.11 mysql mac os x 安装mysq
-
在Mac OS上搭建Nginx+PHP+MySQL开发环境的教程,