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