Download Mysqldb For Python Mac

Connector/Python; MySQL Native Driver for PHP; MySQL Benchmark Tool; Time zone description tables; Download Archives; Contact MySQL Sales USA/Canada: +1-866-221-0634 (More Countries ». Dec 26, 2018.

Latest version

Released:

Python interface to MySQL

Project description

MySQLdb is an interface to the popular MySQL database server forPython. The design goals are:

  • Compliance with Python database API version 2.0 [PEP-0249]
  • Thread-safety
  • Thread-friendliness (threads will not block each other)

MySQL-3.23 through 5.5 and Python-2.4 through 2.7 are currentlysupported. Python-3.0 will be supported in a future release.PyPy is supported.

MySQLdb is Free Software.

[PEP-0249]http://www.python.org/peps/pep-0249.html

Release historyRelease notifications RSS feed

1.2.5

1.2.4

1.2.4c1 pre-release

1.2.4b5 pre-release

1.2.4b4 pre-release

1.2.4b3 pre-release

1.2.4b2 pre-release

1.2.4b1 pre-release

1.2.3

1.2.3c1 pre-release

1.2.3b2 pre-release

1.2.3b1 pre-release

1.2.2

1.2.2c1 pre-release

1.2.2b3 pre-release

1.2.2b2 pre-release

1.2.2b1 pre-release

1.2.1

1.2.1c6 pre-release

1.2.1c5 pre-release

1.2.1c4 pre-release

1.2.1_p2

1.2.0

1.1.10

1.1.9

1.1.8

1.0.1

1.0.0

0.9.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for MySQL-python, version 1.2.5
Filename, sizeFile typePython versionUpload dateHashes
Filename, size MySQL-python-1.2.5.win32-py2.7.exe (1.1 MB) File type Windows Installer Python version 2.7 Upload dateHashes
Filename, size MySQL-python-1.2.5.zip (108.9 kB) File type Source Python version None Upload dateHashes
Close

Hashes for MySQL-python-1.2.5.win32-py2.7.exe

Hashes for MySQL-python-1.2.5.win32-py2.7.exe
AlgorithmHash digest
SHA256ab22d1322099098730a57fd59d610f60738f95a1cb68dacca2d1c47cb0cbe8ee
MD56f43f42516ea26e79cfb100af69a925e
BLAKE2-2562706596ae3afeefc0cda5840036c42920222cb8136c101ec0f453f2e36df12a0
Close

Hashes for MySQL-python-1.2.5.zip

Hashes for MySQL-python-1.2.5.zip
AlgorithmHash digest
SHA256811040b647e5d5686f84db415efd697e6250008b112b6909ba77ac059e140c74
MD5654f75b302db6ed8dc5a898c625e030c
BLAKE2-256a5e951b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad

2020腾讯云10周年活动,优惠非常大!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1040

2020阿里云最低价产品入口,含代金券(新老用户有优惠),
入口地址:https://www.aliyun.com/minisite/goods

I'm a Python newbie, but I've just spent a day working out how to get MySQLdb working properly, and the universe according to google includes numerous references to what a PITA it is, and an inordinate number of guides that seem to be outdated. Given that this site is intended to address these sorts of problems, and I know that I'm going to need a reference to the solution in future, I'm going to ask the question, provide my answer and see what else floats to the surface.

So the question is how to get MySQLdb working on Mac OS X?

pythonmysqlosxDownload Mysqldb For Python Mac

this questionedited Aug 14 '12 at 13:10demongolem 5,557 12 56 81 asked Sep 19 '09 at 12:04 mblackwell8 2,169 2 14 22

11 Answers
11

Here is the tale of my rambling experience with this problem. Would love to see it edited or generalised if you have better experience of the issue.. apply a bit of that SO magic.

Note: Comments in next paragraph applied to Snow Leopard, but not to Lion, which appears to require 64-bit MySQL

First off, the author (still?) of MySQLdb says here that one of the most pernicious problems is that OS X comes installed with a 32 bit version of Python, but most average joes (myself included) probably jump to install the 64 bit version of MySQL. Bad move.. remove the 64 bit version if you have installed it (instructions on this fiddly task are available on SO here), then download and install the 32 bit version (package here)

There are numerous step-by-steps on how to build and install the MySQLdb libraries. They often have subtle differences. This seemed the most popular to me, and provided the working solution. I've reproduced it with a couple of edits below

Step 0: Before I start, I assume that you have MySQL, Python, and GCC installed on the mac.

Step 1: Download the latest MySQL for Python adapter from SourceForge.

Step 2: Extract your downloaded package:

Step 3: Inside the folder, clean the package:

COUPLE OF EXTRA STEPS, (from this comment)

Step 3b: Remove everything under your MySQL-python-1.2.2/build/* directory -- don't trust the 'python setup.py clean' to do it for you

Step 3c: Remove the egg under Users/$USER/.python-eggs

Step 4: Originally required editing _mysql.c, but is now NO LONGER NECESSARY. MySQLdb community seem to have fixed this bug now.

Step 5: Create a symbolic link under lib to point to a sub-directory called mysql. This is where it looks for during compilation.

Step 6: Edit the setup_posix.py and change the following

mysql_config.path = 'mysql_config'

to

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

Step 7: In the same directory, rebuild your package (ignore the warnings that comes with it)

Step 8: Install the package and you are done.

Step 9: Test if it's working. It works if you can import MySQLdb.

>>> import MySQLdb

Step 10: If upon trying to import you receive an error complaining that Library not loaded: libmysqlclient.18.dylib ending with: Reason: image not found you need to create one additional symlink which is:

You should then be able to import MySQLdb without any errors.

One final hiccup though is that if you start Python from the build directory you will get this error:

/Library/Python/2.5/site-packages/MySQL_python-1.2.3c1-py2.5-macosx-10.5-i386.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Python/2.5/site-packages/MySQL_python-1.2.3c1-py2.5-macosx-10.5-i386.egg/_mysql.pyc, but XXXX/MySQL-python-1.2.3c1 is being added to sys.path

This is pretty easy to Google, but to save you the trouble you will end up here (or maybe not.. not a particularly future-proof URL) and figure out that you need to cd . out of build directory and the error should disappear.

Python mysqldb connect

As I wrote at the top, I'd love to see this answer generalised, as there are numerous other specific experiences of this horrible problem out there. Edit away, or provide your own, better answer.



this answeredited Mar 28 '13 at 18:55Rob Watts 4,763 18 38 answered Sep 19 '09 at 12:37 mblackwell8 2,169 2 14 22 1 Note that the Apple-supplied Python on 10.6 (Snow Leopard) prefers to run 64-bit (it's 32-bit/64-bit universal). There are other pitfalls, too. For a while in the mysql 5.1.x series, the OS X tarballs packaged by mysql were faulty (claimed to be universal but weren't). The data base adapter for Python, MySQLdb, has had its own issues. This is one case where you are well advised to just use MacPorts to build everything you need automatically. It's just too easy for something to go wrong. – Ned Deily Sep 19 '09 at 18:24 I'm going to leave this here in case it helps anybody else. I also had to modify site.cfg to set the mysql_config to the right path. I don't think it had a path initially, so was defaulting to /opt/.., but I needed to point it to /usr/local/mysql/.. – tchaymore Apr 19 '11 at 16:57 8 I also had to run: sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib – David Underhill Dec 5 '12 at 22:54 1 I am running on Lion as well, and I had massive problems getting this to work. I finally found this great SO question and answer and followed it 100%. It did not work for me until I added, exactly as David Underhill noted above: sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib. Once I ran this, it imported as expected..finally. Wheewwww. Just an fyi for those in a similar position. – JohnZ Feb 7 '13 at 18:03 1 Thanks for step 10. +1 – keyser Aug 2 '13 at 11:08 show more comments

A quick and easy way for Mac OS X 10.8 (Mountain Lion), 10.9 (Mavericks), 10.10 (Yosemite), and 10.11 (El Capitan):

I assume you have XCode, its command line tools, Python, and MySQL installed.

  1. Install PIP:

  2. Edit ~/.profile: (Might not be necessary in Mac OS X 10.10)

    Copy and paste the following two line

    Save and exit. Afterwords execute the following command:

  3. Install MySQLdb

    To test if everything works fine just try

It worked like a charm for me. I hope it helps.

If you encounter an error regarding a missing library: Library not loaded: libmysqlclient.18.dylib then you have to symlink it to /usr/lib like so:



this answeredited Nov 12 '16 at 23:25 answered Aug 12 '13 at 1:32 F Lekschas 7,480 3 29 44 2 Thank you, this solution works also on Mac OSX 10.9 :-) – matsoftware Jan 27 '14 at 13:59 1 Thanks, worked for me. OSX 10.8. – Matt Montag Jan 31 '14 at 2:34 1 This solved it for me - OSX 10.9.2 – Garfonzo Mar 7 '14 at 22:45 This worked for me on 10.7.5 – mtbomb May 31 '14 at 23:50 2 This worked great for me (Yosemite public beta; Mysql 5; Py2.7), but I needed to do the sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib command from below. – Michael Scott Cuthbert Aug 17 '14 at 21:42 show more comments

Install mysql and python via Macports The porters have done all the difficult work.

should install what you need. (see Stack overflow for comments re mysql server)

If you only need to connect to mysql and not run a server then the first line is sufficient.

Macports now (early 2013) will provide binary downloads for common combinations of OS a executable architecture, for others (and if you request it) it will build from source.

In general macports (or fink) help when there are complex libraries etc that need to be installed.

Recommend:mysql - Error importing MySQLdb for Python on Mac OS X

gure out how to install a MySQL server and MySQLdb for Python on my Mac OS 10.6.7. I think I got the MySQL server installed through MacPorts(which took an eternity), but I can't import MySQLdb (downloaded from here) with Python. Here's the

Python only code and if simple C dependencies can be set up via setuptools etc, but it begins to get complex if you mix the two.



this answeredited Apr 15 '13 at 8:41 answered Sep 19 '09 at 12:17 Mark 25.4k 8 65 89 3 Note that when starting use MacPorts, make sure that your path prefers /opt/local/bin over /usr/bin as MacPorts installs things under /opt/local. – Teemu Kurppa Sep 19 '09 at 12:40 4 Yes! And skip the second line if you just need to connect to an existing MySQL server. Unfortunately, with the number of dependencies involved, trying to use python with mysql on OS X is one case where it is easier to let MacPorts install an additional python instance rather than trying to play package manager yourself. – Ned Deily Sep 19 '09 at 18:13 This worked great, thanks! – Jay Taylor Oct 13 '10 at 16:12 As a sidenote, if you are getting a deprecation warning, the following page has the fix: bugs.launchpad.net/python-mysqldb/+bug/341943 – Jay Taylor Oct 13 '10 at 16:48 4 FYI, if you just do the first line (with py27-mysql at least), it'll end up installing mysql5 anyway. By downloading and compiling the source. Probably not what you want. Grr. – Ben Hardy Jul 5 '12 at 17:40 show more comments

Here's another step I had to go through, after receiving an error on completing Step 9:

Reference: Thanks! http://ageekstory.blogspot.com/2011_04_01_archive.html



Download Mysqldb For Python Macro

this answeredited Nov 25 '11 at 14:22antyrat 21.5k 8 46 67 answered May 17 '11 at 2:07 Richard Boardman 740 9 10

Install pip:

Install brew:

Install mysql:

Install MySQLdb

If you have compilation problems, try editing the ~/.profile file like in one of the answers here.



this answeredited Feb 16 '14 at 16:25awestley 37 5 answered Nov 4 '13 at 13:46 Ron Reiter 2,140 20 31

As statend on Installing MySQL-python on mac :

Then test it :



this answer answered Mar 19 '14 at 17:41 Telmo Dias 1,806 14 21

Just had this problem (again!) after getting a new Lion box.

Best solution I've found (still not 100% optimal, but working):

  • make sure you have 64-bit python. How to check if a library is 32bit/64bit built on Mac OS X?

  • install easy_install if you don't have it. http://packages.python.org/distribute/easy_install.html

  • install GCC if you don't have it.

you can get it by downloading XCode/Dev Tools from Apple - this is a big download -

.. but instead I recommend this github which has what you need (and does not have XCode): https://github.com/kennethreitz/osx-gcc-installer

I downloaded their prebuilt PKG for lion, https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg

  • make sure you have downloaded a 64-BIT version of MYSQL Community. (The DMG install is an easy route) http://dev.mysql.com/downloads/mysql/

  • Set paths as follows:

    export PATH=$PATH:/usr/local/mysql-XXXX

    export DYLD_LIBRARY_PATH = /usr/local/mysql/lib/

    export ARCHFLAGS='-arch x86_64'

NOTE THAT: Lightroom 5 download mac crack.

1 in mysql-XXXX above, XXX is the specific version you downloaded. (Probably /usr/local/mysql/ would also work since this is most likely an alias to the same, but I won't pretend to know your setup)

2 I have seen it suggested that ARCHFLAGS be set to '-arch i386 -arch x86_64' but specifying only x86_64 seemed to work better for me. (I can think of some reasons for this but they are not strictly relevant).

  • Install the beast!

    easy_install MySQL-python

  • LAST STEP:

Permanently add the DYLD_LIBRARY_PATH!

You can add it to your bash_profile or similar. This was the missing step for me, without which my system continued to insist on various errors finding _mysql.so and so on.

export DYLD_LIBRARY_PATH = /usr/local/mysql/lib/

@richard-boardman, just noticed your soft link solution, which may in effect be doing the same thing my PATH solution does..folks, whatever works best for you.

Best reference: http://activeintelligence.org/blog/archive/mysql-python-aka-mysqldb-on-osx-lion/



this answer answered Dec 13 '12 at 19:46 jsh 1,575 14 26

Or simple try:

sudo easy_install MySQL-python

If it gives a error

EnvironmentError: mysql_config not found

Just run this

export PATH=$PATH:/usr/local/mysql/bin



this answer answered May 24 '14 at 20:59 Shashank Agarwal 570 5 11

You could try using the pure-python pymysql:

(Or use pip if you have it installed.) Then, add this before you import MySQLdb in your code:


Download Mysqldb Python 2.7


this answer answered Apr 5 '14 at 20:15 Collin Anderson 5,081 3 34 36

If you are using 64 bit MySQL, using ARCHFLAGS to specify your cpu architecture while building mysql-python libraries would do the trick:



this answer answered Feb 14 '13 at 11:07 Shan Valleru 2,137 1 13 19

should fix the issue for you as the system is not able to find the mysql_config file.


Python Mysqldb Tutorial


Python Mysqldb Download

this answer answered May 26 '14 at 12:00 Varun Bhatia 2,191 19 30

protected by Andrew Barber Mar 9 '13 at 8:24

Mysqldb Install Python

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged pythonmysqlosx or ask your own question.

Recommend:osx - Unable to install openfst python library on Mac OS X Yosemite

Download Mysqldb For Python Mac Download

I have read all similar questions on stack overflow and other websites but none of the instructions work. I have the latest Xcode installed, using brew install openfst I also installed openfst, however when I want to install the python li