mac os x10.9,mysql及Python相關

來源:互聯網
上載者:User

標籤:http   ar   os   使用   sp   for   strong   資料   on   

mysql:

升級mac到osx10.9後,mysql伺服器不能用了,在網上查到資料說 OSX 10.9 下的 Server 軟體進行了不少升級,所以重新下載了適配10.9的mysql伺服器

:http://dev.mysql.com/downloads/mysql/,開啟後下載適配osx10.9的dmg版本即可。

OS X 10.9 是一個純64位的作業系統. 下載的時候也無需註冊 , 找到 No thanks, just start my download. 即可.

下載完畢後,開啟系統喜好設定,點擊MySQL,開啟伺服器。

Python-MySQLdb:

以前說了max os x下安裝mysql,我們需要使用python訪問mysql資料庫,需要安裝MySQLdb模組,方法如下:

在下面的網址下載mysqldb模組:

http://sourceforge.net/projects/mysql-python/

在mac os x直接雙擊解壓,命令列進入解壓後的目錄, 執行python setup.py build

如果有

sh: mysql_config: command not found

提示,我們需要編輯下mysql的路徑,使用vim開啟setup_posix.py

找到:

mysql_config.path = "mysql_config"

改為:

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

然後執行:

sudo python setup.py install

安裝成功後,在命令列輸入python進入python環境,輸入import MySQLdb,我的環境中報下面的錯誤:

>>> import MySQLdbTraceback (most recent call last):  File "<stdin>", line 1, in <module>  File "MySQLdb/__init__.py", line 19, in </module><module>    import _mysqlImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib  Referenced from: /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so  Reason: image not found

解決方案,我們建立一個軟鏈就可以了

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

這樣我們就在mac os x的python環境下安裝好了MySQLdb模組

mac os x10.9,mysql及Python相關

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.