Hi, when I run a python script from mod_python which uses MySQLdb there occurs an error in _mysql.c when the function mysql_server_init() of MySQL's embedded C api is called.
In my python script this shows up as
InternalError: (-1, 'server not initialized')
This error however does not occur when I run my script directly from python interpreter. I am aware of http://modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp
But according to my provider, the php4 module was compiled with the path to the system mysql library given.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Are you actually linked against the embedded libraries? I'm not sure the embedded libraries would work with mod_python; certainly that's not something I've tested. mysql_server_init() is also presented in the regular client library, so it is not an error to call it in a non-embedded environment.
0000000000004e95 t _mysql_server_init
U mysql_server_init
000000000010b6c0 d _mysql_server_initdoc
000000000010ef40 B _mysql_server_init_done
Note that mysql_server_init is U (undefined) because of dynamic linking. If you see t (text) and an address instead, it is statically-linked. A static version might interfere with the dynamic library that mod_php is using. The very fact that you are getting an InternalError indicates that you are linked against the client library in some way; otherwise you wouldn't even be able to import. Dynamic linking will probably work better in this case.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I checked it, and indeed MySQLdb is linked with the static version of the mysqlclient library. Furthermore there don't seem to be installed any shared versions of libmysqlclient, so mod_php should be linked against a static version also.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't think the embedded library can co-exist with the regular client library in the same process, so it's always going to interfere with whatever mod_php is using.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem's now resolved. I apologize, the problem was indeed that mod_php was using the built-in library. My provider inadvertently told me that mod_php was using the external library.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, when I run a python script from mod_python which uses MySQLdb there occurs an error in _mysql.c when the function mysql_server_init() of MySQL's embedded C api is called.
In my python script this shows up as
InternalError: (-1, 'server not initialized')
This error however does not occur when I run my script directly from python interpreter. I am aware of http://modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp
But according to my provider, the php4 module was compiled with the path to the system mysql library given.
Are there any developers in this forum? I really need a response soon.
My provider is using MySQL 4.1, MySQLdb 1.21 and mod_python 2.7.8
What version of Python?
Are you actually linked against the embedded libraries? I'm not sure the embedded libraries would work with mod_python; certainly that's not something I've tested. mysql_server_init() is also presented in the regular client library, so it is not an error to call it in a non-embedded environment.
Compare the output of:
ldd /usr/lib/python2.4/site-packages/_mysql.so
ldd /usr/lib/apache2/modules/libphp4.so
(Adjust paths for versions) Make sure they link against the same version of libmysqlclient.so (should be 14 for 4.1).
The MySQLdb module wasn't compiled with the embedded libraries.
When I run /usr/local/lib/python2.4/site-packages/_mysql.so I get the following output
So _mysql.so doesn't appear to be linked against libmysqlclient.so
Well, you could be statically-linked. Run:
nm /usr/local/lib/python2.4/site-packages/_mysql.so | grep mysql_server_init
On my system:
0000000000004e95 t _mysql_server_init
U mysql_server_init
000000000010b6c0 d _mysql_server_initdoc
000000000010ef40 B _mysql_server_init_done
Note that mysql_server_init is U (undefined) because of dynamic linking. If you see t (text) and an address instead, it is statically-linked. A static version might interfere with the dynamic library that mod_php is using. The very fact that you are getting an InternalError indicates that you are linked against the client library in some way; otherwise you wouldn't even be able to import. Dynamic linking will probably work better in this case.
I checked it, and indeed MySQLdb is linked with the static version of the mysqlclient library. Furthermore there don't seem to be installed any shared versions of libmysqlclient, so mod_php should be linked against a static version also.
Ok, I now have MySQLdb linked dynamically with libmysqlclient. Doing "ldd /usr/local/lib/python2.4/site-packages/_mysql.so" now gives me
libmysqlclient.so.14 => /usr/lib/libmysqlclient.so.14 (0x0088e000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0075d000)
libc.so.6 => /lib/tls/libc.so.6 (0x00111000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00b44000)
libnsl.so.1 => /lib/libnsl.so.1 (0x007cc000)
libm.so.6 => /lib/tls/libm.so.6 (0x009d2000)
libz.so.1 => /usr/lib/libz.so.1 (0x00738000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00531000)
What versions of MySQL and MySQLdb and Python and mod_python?
So now I have dynamically linked MySQLdb with libmysqlclient, but still I get
InternalError: (-1, 'server not initialized')
when using MySQLdb from mod_python. I'm really clueless what might be the cause for this, so any help would be appreciated.
I don't think the embedded library can co-exist with the regular client library in the same process, so it's always going to interfere with whatever mod_php is using.
I'm not linked against the embedded library at all.
The problem's now resolved. I apologize, the problem was indeed that mod_php was using the built-in library. My provider inadvertently told me that mod_php was using the external library.
And the problem persists, in fact the situation is as before.