comparison doc/FAQ.txt @ 0:e48810735f11 MySQLdb

Copying 1.2.1 to be the new trunk
author adustman
date Sun, 02 Apr 2006 18:20:53 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e48810735f11
1 ====================================
2 MySQLdb Frequently Asked Questions
3 ====================================
4
5 .. contents::
6 ..
7
8
9 Build Errors
10 ------------
11
12 ld: fatal: library -lmysqlclient_r: not found
13
14 mysqlclient_r is the thread-safe library. It's not available on
15 all platforms, or all installations, apparently. You'll need to
16 reconfigure site.cfg (in MySQLdb-1.2.1 and newer) to have
17 threadsafe = False.
18
19 mysql.h: No such file or directory
20
21 This almost always mean you don't have development packages
22 installed. On some systems, C headers for various things (like MySQL)
23 are distributed as a seperate package. You'll need to figure out
24 what that is and install it, but often the name ends with -devel.
25
26 Another possibility: Some older versions of mysql_config behave oddly
27 and may throw quotes around some of the path names, which confused
28 MySQLdb-1.2.0. 1.2.1 works around these problems. If you see things
29 like -I'/usr/local/include/mysql' in your compile command, that's
30 probably the issue, but it shouldn't happen any more.
31
32
33 ImportError
34 -----------
35
36 ImportError: No module named _mysql
37
38 If you see this, it's likely you did some wrong when installing
39 MySQLdb; re-read (or read) README. _mysql is the low-level C module
40 that interfaces with the MySQL client library.
41
42 Various versions of MySQLdb in the past have had build issues on
43 "weird" platforms; "weird" in this case means "not Linux", though
44 generally there aren't problems on Unix/POSIX platforms, including
45 BSDs and Mac OS X. Windows has been more problematic, in part because
46 there is no `mysql_config` available in the Windows installation of
47 MySQL. 1.2.1 solves most, if not all, of these problems, but you will
48 still have to edit a configuration file so that the setup knows where
49 to find MySQL and what libraries to include.
50
51
52 ImportError: libmysqlclient_r.so.14: cannot open shared object file: No such file or directory
53
54 The number after .so may vary, but this means you have a version of
55 MySQLdb compiled against one version of MySQL, and are now trying to
56 run it against a different version. The shared library version tends
57 to change between major releases.
58
59 Solution: Rebuilt MySQLdb, or get the matching version of MySQL.
60
61 Another thing that can cause this: The MySQL libraries may not be on
62 your system path.
63
64 Solutions:
65
66 * set the LD_LIBRARY_PATH environment variable so that it includes
67 the path to the MySQL libraries.
68
69 * set static=True in site.cfg for static linking
70
71 * reconfigure your system so that the MySQL libraries are on the
72 default loader path. In Linux, you edit /etc/ld.so.conf and run
73 ldconfig. For Solaris, see `Linker and Libraries Guide
74 <http://docs.sun.com/app/docs/doc/817-3677/6mj8mbtbe?a=view>`_.
75
76
77 ImportError: ld.so.1: python: fatal: libmtmalloc.so.1: DF_1_NOOPEN tagged object may not be dlopen()'ed
78
79 This is a weird one from Solaris. What does it mean? I have no idea.
80 However, things like this can happen if there is some sort of a compiler
81 or environment mismatch between Python and MySQL. For example, on some
82 commercial systems, you might have some code compiled with their own
83 compiler, and other things compiled with GCC. They don't always mesh
84 together. One way to encounter this is by getting binary packages from
85 different vendors.
86
87 Solution: Rebuild Python or MySQL (or maybe both) from source.
88
89 ImportError: dlopen(./_mysql.so, 2): Symbol not found: _sprintf$LDBLStub
90 Referenced from: ./_mysql.so
91 Expected in: dynamic lookup
92
93 This is one from Mac OS X. It seems to have been a compiler mismatch,
94 but this time between two different versions of GCC. It seems nearly
95 every major release of GCC changes the ABI in some why, so linking
96 code compiled with GCC-3.3 and GCC-4.0, for example, can be
97 problematic.
98
99
100 My data disappeared! (or won't go away!)
101 ----------------------------------------
102
103 Starting with 1.2.0, MySQLdb disables autocommit by default, as
104 required by the DB-API standard (`PEP-249`_). If you are using InnoDB
105 tables or some other type of transactional table type, you'll need
106 to do connection.commit() before closing the connection, or else
107 none of your changes will be written to the database.
108
109 Conversely, you can also use connection.rollback() to throw away
110 any changes you've made since the last commit.
111
112 Important note: Some SQL statements -- specifically DDL statements
113 like CREATE TABLE -- are non-transactional, so they can't be
114 rolled back, and they cause pending transactions to commit.
115
116
117 Other Errors
118 ------------
119
120 OperationalError: (1251, 'Client does not support authentication protocol requested by server; consider upgrading MySQL client')
121
122 This means your server and client libraries are not the same version.
123 More specifically, it probably means you have a 4.1 or newer server
124 and 4.0 or older client. You can either upgrade the client side, or
125 try some of the workarounds in `Password Hashing as of MySQL 4.1
126 <http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html>`_.
127
128
129 Other Resources
130 ---------------
131
132 * Help forum. Please search before posting.
133
134 * `Google <http://www.google.com/>`_
135
136 * READ README!
137
138 * Read the User's Guide
139
140 * Read `PEP-249`_
141
142 .. _`PEP-249`: http://www.python.org/peps/pep-0249.html
143