When attempting to use MySQLdb to connect to mysql.x10hosting.com I get an exception. The exception suggests that the MySQLdb build is incompatable with the current MySQL installation. I'll post it below along with a FAQ entry from the MySQLdb page, and the code.
The exception: libmysqlclient_r.so.14: cannot open shared object file: No such file or directory
FAQ page: http://mysql-python.sourceforge.net/FAQ.html#importerror
From the FAQ page:
And the code that demonstrates the error (of course I've changed the db, user, and passwd settings for posting purposes):
Edit:
A little surprised no one else has mentioned this but it seems the cossacks build of the python module MySQLdb is not compatible with the the new MySQL version on the new server. Can we get a new install of MySQLdb please? Thanks and much appreciated.
Here's some test code that currently throws the exception libmysqlclient_r.so.14: cannot open shared object file: No such file or directory:
file: import_MySQLdb.py
MySQLdb Home on Sourceforge:
http://sourceforge.net/projects/mysql-python
The exception: libmysqlclient_r.so.14: cannot open shared object file: No such file or directory
FAQ page: http://mysql-python.sourceforge.net/FAQ.html#importerror
From the FAQ page:
ImportError: libmysqlclient_r.so.14: cannot open shared object file: No such file or directoryThe number after .so may vary, but this means you have a version of MySQLdb compiled against one version of MySQL, and are now trying to run it against a different version. The shared library version tends to change between major releases.
Solution: Rebuilt MySQLdb, or get the matching version of MySQL.
Another thing that can cause this: The MySQL libraries may not be on your system path.
Solutions:
- set the LD_LIBRARY_PATH environment variable so that it includes the path to the MySQL libraries.
- set static=True in site.cfg for static linking
- reconfigure your system so that the MySQL libraries are on the default loader path. In Linux, you edit /etc/ld.so.conf and run ldconfig. For Solaris, see Linker and Libraries Guide.
And the code that demonstrates the error (of course I've changed the db, user, and passwd settings for posting purposes):
Code:
#!/usr/bin/python
print "Content-type: text/html\n\n"
# attempt to connect to database
try:
import MySQLdb
db=MySQLdb.Connect(db='example_db', host='mysql.x10hosting.com', user='example_user', passwd='example_pwd')
cursor=db.cursor()
cursor.execute('SELECT version()')
data=cursor.fetchall()
cursor.close()
db.close()
print data
except Exception, e:
print e
A little surprised no one else has mentioned this but it seems the cossacks build of the python module MySQLdb is not compatible with the the new MySQL version on the new server. Can we get a new install of MySQLdb please? Thanks and much appreciated.
Here's some test code that currently throws the exception libmysqlclient_r.so.14: cannot open shared object file: No such file or directory:
file: import_MySQLdb.py
Code:
#!/usr/bin/python
print "Content-type: text/html\n\n"
#attempt to import MySQLdb
try:
import MySQLdb
print "MySQLdb imported successfully"
except Exception, e:
print e
http://sourceforge.net/projects/mysql-python
Last edited: