Compatible python and mysql vertions are python 2.5 ,mysql 5.1.30
1. Download the latest MySQL for python adapter from source forge.
2. $tar xzvf MySQL-python-1.2.2.tar.gz
3. Go to the path of MySQL-python-1.2.2 and type this command $ sudo python setup.py clean
4. In MySQL-python-1.2.2 folder , edit the file "_mysql.c"
4a. Remove the following
#ifdef unit
#define unit unsigned int
#endif
4b. change the following
uint port=MySQL-port;
uint client_flag=0;
to
unsigned int port=MySQL_Port;
unsigned int client_flag=0;
5. Create a symbolic link under lib to point to a sub-directory called mysql
$sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
6. Edit the file setup_posix.py
mysql_config.path="mysql_config"
to
mysql_config.path="/usr/local/mysql/bin/mysql_config"
7. $sudo python setup.py build
8. $sudo python setup.py install
Note: If you get a 'gcc' error then try to get gcc package from Apple and install 'X-code' and all related gcc contents.
Now type $ sudo python setup.py clean
$ sudo python setup.py build
$ sudo python setup.py install
then restart your system.
9. Check this one in your python IDLE
>>>import MySQLdb
>>>
Good Luck .....
No comments:
Post a Comment