

- Welcome to Geeksww.com
How to download and install MySQLdb module for Python on Linux?
Please use md5 checksum to make sure the downloaded files are not corrupt. Also, $ before commands mean you can run the command as ordinary user and # means you have to run the command as root (or use $ sudo <command>).
$ wget http://downloads.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz $ tar xzf MySQL-python-1.2.3.tar.gz $ cd MySQL-python-1.2.3 # /opt/python/bin/python setup.py install
That should install MySQLdb module, but in case you get an error complaining about missing mysql_config, do the following inside MySQLdb unzipped folder (use your favorite text editor instead of nano, if you will):
$ nano site.cfg
and find the line that starts with something like the following:
# mysql_config = ...
You have to uncomment it and replace the path with path of mysql_config in your local machine. On my computer, I did the following:
mysql_config = /opt/mysql/bin/mysql_config
Ctrl-O to save and Ctrl-X to exit out of nano and run the following on command line:
# /opt/python-2.7/bin/python setup.py install
That should install the MySQLdb module for your python installation. To verify:
$ ls /opt/python/lib/python2.7/site-packages/ -la | grep MySQL
The output looked like below on my machine:
-rw-r--r-- 1 root root 106932 Nov 4 11:49 MySQL_python-1.2.3-py2.7-linux-x86_64.egg
Did this tutorial help a little? How about buy me a cup of coffee?
Please feel free to use the comments form below if you have any questions or need more explanation on anything. I recommend thoroughy testing on a production-like test system first before moving to production.
tags cloud
popular searches
free download for mysql database server 5.1.5, bison, gearman, install cairo, php, java, install mysql, laptop, linux, mysql mysql, mysql, source code, mysql initialization, tools, ubuntu
Similar Tutorials:
- Fast, parallel restore from SQL dumps (mysqldump) for MySQL
- MySQL GUI Tools - Query Browser
- all-schemas: Tool to run multiple SQL queries on a MySQL database server
- Debian Linux Installation and Hardening (3.1r0a)
- How to download and install Bison (GNU Parser Generator) on Ubuntu Linux
Tutorials in 'Web Development > Python' (more):
- How to install Python Gearman client module?
- How to download and install setuptools module for Python
- How to download, compile, and install Python on Ubuntu/Debian/ CentOS Linux
Comments (write a comment):
Thanks for the help. I confirmed this on Fedora 17, though I needed to install python-devel and mysql-devel before it would work. Also, if you have a 64-bit machine, the mysql package might end up in /usr/lib64/... Check the output of setup.py, it will tell you. Posted by: Brian on Sep 20, 2012
Where exactly should I put the unzipped MySQL-python-1.2.3 folder? Right now it's in my downloads but is it okay to leave it there? Posted by: Stephanie on Feb 08, 2015