0
|
1 ====================
|
|
2 MySQLdb Installation
|
|
3 ====================
|
|
4
|
|
5 .. contents::
|
|
6 ..
|
|
7
|
|
8 Prerequisites
|
|
9 -------------
|
|
10
|
|
11 + Python 2.3.4 or higher
|
|
12
|
|
13 * http://www.python.org/
|
|
14
|
|
15 * Versions lower than 2.3 WON'T WORK.
|
|
16
|
|
17 * 2.4 is the primary test environment.
|
|
18
|
|
19 * Red Hat Linux:
|
|
20
|
|
21 - Make sure you have the Python development headers and libraries
|
|
22 (python-devel).
|
|
23
|
34
|
24 + setuptools
|
|
25
|
|
26 * http://pypi.python.org/pypi/setuptools
|
|
27
|
0
|
28 + MySQL 3.23.32 or higher
|
|
29
|
|
30 * http://www.mysql.com/downloads/
|
|
31
|
|
32 * Versions lower than 3.22 definitely WON'T WORK.
|
|
33
|
|
34 * Versions lower than 3.22.19 might not work.
|
|
35
|
|
36 * MySQL-3.22 might work but isn't supported anymore. It's very old.
|
|
37
|
|
38 * MySQL-3.23 ought to work, but it's pretty elderly.
|
|
39
|
|
40 * MySQL-4.0 is supported, but not tested and slightly discouraged.
|
|
41
|
34
|
42 * MySQL-4.1 is supported. The prepared statements API is not
|
|
43 supported, and won't be until MySQLdb-1.3 or 2.0, if ever.
|
0
|
44
|
|
45 * MySQL-5.0 is supported and tested, including stored procedures.
|
|
46
|
34
|
47 * MySQL-5.1 is supported (currently a release candidate) but untested.
|
|
48 It should work.
|
|
49
|
|
50 * MySQL-6.0 is sorta-kinda-supported (currently alpha) but untested.
|
|
51 It should work.
|
|
52
|
|
53 * Drizzle <https://launchpad.net/drizzle> is a fork of MySQL. So far
|
|
54 the C API looks really similar except everything is renamed.
|
|
55 Drizzle support probably won't happen in 1.2. There may be have to
|
|
56 be an entirely different module, but still using DB-API.
|
|
57
|
0
|
58 * MaxDB, formerly known as SAP DB (and maybe Adabas D?), is a
|
|
59 completely different animal. Use the sapdb.sql module that comes
|
|
60 with MaxDB.
|
|
61
|
|
62 * Red Hat Linux packages:
|
|
63
|
|
64 - mysql-devel to compile
|
|
65
|
|
66 - mysql and/or mysql-devel to run
|
|
67
|
|
68 * MySQL.com RPM packages:
|
|
69
|
|
70 - MySQL-devel to compile
|
|
71
|
|
72 - MySQL-shared if you want to use their shared
|
|
73 library. Otherwise you'll get a statically-linked module,
|
|
74 which may or may not be what you want.
|
|
75
|
|
76 - MySQL-shared to run if you compiled with MySQL-shared installed
|
|
77
|
|
78 * Transactions (particularly InnoDB tables) are supported for
|
|
79 MySQL-3.23 and up. You may need a special package from your vendor
|
|
80 with this support turned on.
|
|
81
|
|
82 + zlib
|
|
83
|
|
84 * Required for MySQL-3.23 and newer.
|
|
85
|
|
86 * Red Hat Linux
|
|
87
|
|
88 - zlib-devel to compile
|
|
89
|
|
90 - zlib to run
|
|
91
|
|
92 + openssl
|
|
93
|
|
94 * May be needed for MySQL-4.0 or newer, depending on compilation
|
|
95 options. If you need it, you probably already have it.
|
|
96
|
|
97 - you may need openssl-devel on some platforms
|
|
98
|
|
99 + C compiler
|
|
100
|
|
101 * Most free software-based systems already have this, usually gcc.
|
|
102
|
|
103 * Most commercial UNIX platforms also come with a C compiler, or
|
|
104 you can also use gcc.
|
|
105
|
|
106 * If you have some Windows flavor, you usually have to pay extra
|
|
107 for this, or you can use Cygwin_.
|
|
108
|
|
109 .. _Cygwin: http://www.cygwin.com/
|
|
110
|
|
111
|
|
112 Building and installing
|
|
113 -----------------------
|
|
114
|
|
115 The setup.py script uses mysql_config to find all compiler and linker
|
|
116 options, and should work as is on any POSIX-like platform, so long as
|
|
117 mysql_config is in your path.
|
|
118
|
|
119 Depending on which version of MySQL you have, you may have the option
|
|
120 of using three different client libraries. To select the client library,
|
|
121 edit the [options] section of site.cfg:
|
|
122
|
|
123 embedded
|
|
124 use embedded server library (libmysqld) if True; otherwise use
|
|
125 one of the client libraries (default).
|
|
126
|
|
127 threadsafe
|
|
128 thread-safe client library (libmysqlclient_r) if True (default);
|
|
129 otherwise use non-thread-safe (libmysqlclient). You should
|
|
130 always use the thread-safe library if you have the option;
|
|
131 otherwise you *may* have problems.
|
|
132
|
|
133 static
|
|
134 if True, try to link against a static library; otherwise link
|
|
135 against dynamic libraries (default). You may need static linking
|
|
136 to use the embedded server.
|
|
137
|
|
138
|
|
139 Finally, putting it together::
|
|
140
|
|
141 $ tar xfz MySQL-python-1.2.1.tar.gz
|
|
142 $ cd MySQL-python-1.2.1
|
|
143 $ # edit site.cfg if necessary
|
|
144 $ python setup.py build
|
|
145 $ sudo python setup.py install # or su first
|
|
146
|
|
147
|
|
148 Windows
|
|
149 .......
|
|
150
|
|
151 I don't do Windows. However if someone provides me with a package for
|
|
152 Windows, I'll make it available. Don't ask me for help with Windows
|
|
153 because I can't help you.
|
|
154
|
|
155 Generally, though, running setup.py is similar to above::
|
|
156
|
|
157 C:\...> python setup.py install
|
|
158 C:\...> python setup.py bdist_wininst
|
|
159
|
|
160 The latter example should build a Windows installer package, if you
|
|
161 have the correct tools. In any event, you *must* have a C compiler.
|
|
162 Additionally, you have to set an environment variable (mysqlroot)
|
|
163 which is the path to your MySQL installation. In theory, it would be
|
|
164 possible to get this information out of the registry, but like I said,
|
|
165 I don't do Windows, but I'll accept a patch that does this.
|
|
166
|
|
167 On Windows, you will definitely have to edit site.cfg since there is
|
|
168 no mysql_config in the MySQL package.
|
|
169
|
|
170
|
|
171 Zope
|
|
172 ....
|
|
173
|
|
174 If you are using a binary package of Zope, you need run setup.py with
|
|
175 the python executable that came with Zope. Otherwise, you'll install
|
|
176 into the wrong Python tree and Zope (ZMySQLDA) will not be able to
|
|
177 find _mysql.
|
|
178
|
|
179
|
|
180 Binary Packages
|
|
181 ---------------
|
|
182
|
|
183 I don't plan to make binary packages any more. However, if someone
|
|
184 contributes one, I will make it available. Several OS vendors have
|
|
185 their own packages available.
|
|
186
|
|
187
|
|
188 RPMs
|
|
189 ....
|
|
190
|
|
191 If you prefer to install RPMs, you can use the bdist_rpm command with
|
|
192 setup.py. This only builds the RPM; it does not install it. You may
|
|
193 want to use the --python=XXX option, where XXX is the name of the
|
|
194 Python executable, i.e. python, python2, python2.4; the default is
|
|
195 python. Using this will incorporate the Python executable name into
|
|
196 the package name for the RPM so you have install the package multiple
|
|
197 times if you need to support more than one version of Python. You can
|
|
198 also set this in setup.cfg.
|
|
199
|
|
200
|
|
201 Red Hat Linux
|
|
202 .............
|
|
203
|
|
204 MySQL-python is pre-packaged in Red Hat Linux 7.x and newer. This
|
|
205 includes Fedora Core and Red Hat Enterprise Linux. You can also
|
|
206 build your own RPM packages as described above.
|
|
207
|
|
208
|
|
209 Debian GNU/Linux
|
|
210 ................
|
|
211
|
|
212 Packaged as `python-mysqldb`_::
|
|
213
|
|
214 # apt-get install python-mysqldb
|
|
215
|
|
216 Or use Synaptic.
|
|
217
|
|
218 .. _`python-mysqldb`: http://packages.debian.org/python-mysqldb
|
|
219
|
|
220
|
|
221 Ubuntu
|
|
222 ......
|
|
223
|
|
224 Same as with Debian.
|
|
225
|
|
226
|
|
227 Gentoo Linux
|
|
228 ............
|
|
229
|
34
|
230 Packaged as `mysql-python`_. ::
|
0
|
231
|
|
232 # emerge sync
|
|
233 # emerge mysql-python
|
|
234 # emerge zmysqlda # if you use Zope
|
|
235
|
|
236 .. _`mysql-python`: http://packages.gentoo.org/search/?sstring=mysql-python
|
|
237
|
|
238
|
|
239 BSD
|
|
240 ...
|
|
241
|
|
242 MySQL-python is a ported package in FreeBSD, NetBSD, and OpenBSD,
|
|
243 although the name may vary to match OS conventions.
|
|
244
|
|
245
|
|
246 License
|
|
247 -------
|
|
248
|
|
249 GPL or the original license based on Python 1.5.2's license.
|
|
250
|
|
251
|
|
252 :Author: Andy Dustman <[email protected]>
|
|
253 :Revision: $Id$
|