Menu

InternalError: (-1, 'server not initialized')

Help
2006-07-14
2012-09-19
  • Fred Davenhurst

    Fred Davenhurst - 2006-07-14

    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.

     
    • Fred Davenhurst

      Fred Davenhurst - 2006-07-17

      Are there any developers in this forum? I really need a response soon.

       
      • Fred Davenhurst

        Fred Davenhurst - 2006-07-17

        My provider is using MySQL 4.1, MySQLdb 1.21 and mod_python 2.7.8

         
        • Andy Dustman

          Andy Dustman - 2006-07-17

          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).

           
          • Fred Davenhurst

            Fred Davenhurst - 2006-07-17
            • The Python version is 2.4.3
            • 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

              libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0086d000)
              libcrypt.so.1 => /lib/libcrypt.so.1 (0x00329000)
              libnsl.so.1 => /lib/libnsl.so.1 (0x00cbc000)
              libm.so.6 => /lib/tls/libm.so.6 (0x00111000)
              libc.so.6 => /lib/tls/libc.so.6 (0x008f7000)
              /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00531000)
              

            So _mysql.so doesn't appear to be linked against libmysqlclient.so

             
            • Andy Dustman

              Andy Dustman - 2006-07-18

              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.

               
              • Fred Davenhurst

                Fred Davenhurst - 2006-07-18

                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.

                 
                • Fred Davenhurst

                  Fred Davenhurst - 2006-10-02

                  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)

                   
    • Andy Dustman

      Andy Dustman - 2006-07-17

      What versions of MySQL and MySQLdb and Python and mod_python?

       
    • Fred Davenhurst

      Fred Davenhurst - 2006-10-10

      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.

       
      • Andy Dustman

        Andy Dustman - 2006-10-10

        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.

         
    • Fred Davenhurst

      Fred Davenhurst - 2006-10-11

      I'm not linked against the embedded library at all.

       
    • Fred Davenhurst

      Fred Davenhurst - 2006-10-11

      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.

       
    • Fred Davenhurst

      Fred Davenhurst - 2006-10-03

      And the problem persists, in fact the situation is as before.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.