Home > Database > Mysql Tutorial > mac os 上安装mysqldb,EnvironmentError: mysql

mac os 上安装mysqldb,EnvironmentError: mysql

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:08:41
Original
1211 people have browsed it

$ 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=<span>"</span><span>/usr/local/mysql/bin:${PATH}</span><span>"</span><span>
export PATH
export DYLD_LIBRARY_PATH</span>=/usr/local/mysql/lib/<span>
export VERSIONER_PYTHON_PREFER_64_BIT</span>=yes<span>
export VERSIONER_PYTHON_PREFER_32_BIT</span>=no
Copy after login

参考:http://stackoverflow.com/questions/1465846/install-mysqldb-on-snow-leopard/6537345#6537345

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
mac use
From 1970-01-01 08:00:00
0
0
0
How to install it on Mac?
From 1970-01-01 08:00:00
0
0
0
Why doesn’t Mac have PHPstudy?
From 1970-01-01 08:00:00
0
0
0
When will phpstudy release a mac version?
From 1970-01-01 08:00:00
0
0
0
Where is the telnet option on mac computer?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template