| 1 |
2.4.15 MySQL Installation Using a Source Distribution |
| 2 |
----------------------------------------------------- |
| 3 |
|
| 4 |
* Menu: |
| 5 |
|
| 6 |
* quick-install:: Source Installation Overview |
| 7 |
* configure-options:: Typical `configure' Options |
| 8 |
* installing-source-tree:: Installing from the Development Source Tree |
| 9 |
* compilation-problems:: Dealing with Problems Compiling MySQL |
| 10 |
* mit-pthreads:: MIT-pthreads Notes |
| 11 |
* windows-source-build:: Installing MySQL from Source on Windows |
| 12 |
* windows-client-compiling:: Compiling MySQL Clients on Windows |
| 13 |
|
| 14 |
This section does not apply to MySQL Enterprise Server users. |
| 15 |
|
| 16 |
Before you proceed with an installation from source, first check |
| 17 |
whether our binary is available for your platform and whether it works |
| 18 |
for you. We put a great deal of effort into ensuring that our binaries |
| 19 |
are built with the best possible options. |
| 20 |
|
| 21 |
To obtain a source distribution for MySQL, *note getting-mysql::. If |
| 22 |
you want to build MySQL from source on Windows, see *note |
| 23 |
windows-source-build::. |
| 24 |
|
| 25 |
MySQL source distributions are provided as compressed `tar' archives |
| 26 |
and have names of the form `mysql-VERSION.tar.gz', where VERSION is a |
| 27 |
number like `5.0.52'. |
| 28 |
|
| 29 |
You need the following tools to build and install MySQL from source: |
| 30 |
|
| 31 |
* GNU `gunzip' to uncompress the distribution. |
| 32 |
|
| 33 |
* A reasonable `tar' to unpack the distribution. GNU `tar' is known |
| 34 |
to work. Some operating systems come with a preinstalled version |
| 35 |
of `tar' that is known to have problems. For example, the `tar' |
| 36 |
provided with early versions of Mac OS X `tar', SunOS 4.x and |
| 37 |
Solaris 8 and earlier are known to have problems with long |
| 38 |
filenames. On Mac OS X, you can use the preinstalled `gnutar' |
| 39 |
program. On other systems with a deficient `tar', you should |
| 40 |
install GNU `tar' first. |
| 41 |
|
| 42 |
* A working ANSI C++ compiler. `gcc' 2.95.2 or later, SGI C++, and |
| 43 |
SunPro C++ are some of the compilers that are known to work. |
| 44 |
`libg++' is not needed when using `gcc'. `gcc' 2.7.x has a bug |
| 45 |
that makes it impossible to compile some perfectly legal C++ |
| 46 |
files, such as `sql/sql_base.cc'. If you have only `gcc' 2.7.x, |
| 47 |
you must upgrade your `gcc' to be able to compile MySQL. `gcc' |
| 48 |
2.8.1 is also known to have problems on some platforms, so it |
| 49 |
should be avoided if a new compiler exists for the platform. |
| 50 |
|
| 51 |
`gcc' 2.95.2 or later is recommended when compiling MySQL 3.23.x. |
| 52 |
|
| 53 |
* A good `make' program. GNU `make' is always recommended and is |
| 54 |
sometimes required. (BSD `make' fails, and vendor-provided `make' |
| 55 |
implementations may fail as well.) If you have problems, we |
| 56 |
recommend GNU `make' 3.75 or newer. |
| 57 |
|
| 58 |
If you are using a version of `gcc' recent enough to understand the |
| 59 |
`-fno-exceptions' option, it is _very important_ that you use this |
| 60 |
option. Otherwise, you may compile a binary that crashes randomly. We |
| 61 |
also recommend that you use `-felide-constructors' and `-fno-rtti' |
| 62 |
along with `-fno-exceptions'. When in doubt, do the following: |
| 63 |
|
| 64 |
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \ |
| 65 |
-fno-exceptions -fno-rtti" ./configure \ |
| 66 |
--prefix=/usr/local/mysql --enable-assembler \ |
| 67 |
--with-mysqld-ldflags=-all-static |
| 68 |
|
| 69 |
On most systems, this gives you a fast and stable binary. |
| 70 |
|
| 71 |
If you run into problems and need to file a bug report, please use the |
| 72 |
instructions in *note bug-reports::. |
| 73 |
|
| 74 |
File: manual.info, Node: quick-install, Next: configure-options, Prev: installing-source, Up: installing-source |
| 75 |
|
| 76 |
2.4.15.1 Source Installation Overview |
| 77 |
..................................... |
| 78 |
|
| 79 |
This section does not apply to MySQL Enterprise Server users. |
| 80 |
|
| 81 |
The basic commands that you must execute to install a MySQL source |
| 82 |
distribution are: |
| 83 |
|
| 84 |
shell> groupadd mysql |
| 85 |
shell> useradd -g mysql mysql |
| 86 |
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf - |
| 87 |
shell> cd mysql-VERSION |
| 88 |
shell> ./configure --prefix=/usr/local/mysql |
| 89 |
shell> make |
| 90 |
shell> make install |
| 91 |
shell> cp support-files/my-medium.cnf /etc/my.cnf |
| 92 |
shell> cd /usr/local/mysql |
| 93 |
shell> chown -R mysql . |
| 94 |
shell> chgrp -R mysql . |
| 95 |
shell> bin/mysql_install_db --user=mysql |
| 96 |
shell> chown -R root . |
| 97 |
shell> chown -R mysql var |
| 98 |
shell> bin/mysqld_safe --user=mysql & |
| 99 |
|
| 100 |
If you start from a source RPM, do the following: |
| 101 |
|
| 102 |
shell> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm |
| 103 |
|
| 104 |
This makes a binary RPM that you can install. For older versions of |
| 105 |
RPM, you may have to replace the command `rpmbuild' with `rpm' instead. |
| 106 |
|
| 107 |
*Note*: |
| 108 |
|
| 109 |
This procedure does not set up any passwords for MySQL accounts. After |
| 110 |
following the procedure, proceed to *note post-installation::, for |
| 111 |
post-installation setup and testing. |
| 112 |
|
| 113 |
A more detailed version of the preceding description for installing |
| 114 |
MySQL from a source distribution follows: |
| 115 |
|
| 116 |
1. Add a login user and group for `mysqld' to run as: |
| 117 |
|
| 118 |
shell> groupadd mysql |
| 119 |
shell> useradd -g mysql mysql |
| 120 |
|
| 121 |
These commands add the `mysql' group and the `mysql' user. The |
| 122 |
syntax for `useradd' and `groupadd' may differ slightly on |
| 123 |
different versions of Unix, or they may have different names such |
| 124 |
as `adduser' and `addgroup'. |
| 125 |
|
| 126 |
You might want to call the user and group something else instead |
| 127 |
of `mysql'. If so, substitute the appropriate name in the |
| 128 |
following steps. |
| 129 |
|
| 130 |
2. Perform the following steps as the `mysql' user, except as noted. |
| 131 |
|
| 132 |
3. Pick the directory under which you want to unpack the distribution |
| 133 |
and change location into it. |
| 134 |
|
| 135 |
4. Obtain a distribution file using the instructions in *note |
| 136 |
getting-mysql::. |
| 137 |
|
| 138 |
5. Unpack the distribution into the current directory: |
| 139 |
|
| 140 |
shell> gunzip < /PATH/TO/MYSQL-VERSION.tar.gz | tar xvf - |
| 141 |
|
| 142 |
This command creates a directory named `mysql-VERSION'. |
| 143 |
|
| 144 |
With GNU `tar', no separate invocation of `gunzip' is necessary. |
| 145 |
You can use the following alternative command to uncompress and |
| 146 |
extract the distribution: |
| 147 |
|
| 148 |
shell> tar zxvf /PATH/TO/MYSQL-VERSION-OS.tar.gz |
| 149 |
|
| 150 |
6. Change location into the top-level directory of the unpacked |
| 151 |
distribution: |
| 152 |
|
| 153 |
shell> cd mysql-VERSION |
| 154 |
|
| 155 |
Note that currently you must configure and build MySQL from this |
| 156 |
top-level directory. You cannot build it in a different directory. |
| 157 |
|
| 158 |
7. Configure the release and compile everything: |
| 159 |
|
| 160 |
shell> ./configure --prefix=/usr/local/mysql |
| 161 |
shell> make |
| 162 |
|
| 163 |
When you run `configure', you might want to specify other options. |
| 164 |
Run `./configure --help' for a list of options. *note |
| 165 |
configure-options::, discusses some of the more useful options. |
| 166 |
|
| 167 |
If `configure' fails and you are going to send mail to a MySQL |
| 168 |
mailing list to ask for assistance, please include any lines from |
| 169 |
`config.log' that you think can help solve the problem. Also |
| 170 |
include the last couple of lines of output from `configure'. To |
| 171 |
file a bug report, please use the instructions in *note |
| 172 |
bug-reports::. |
| 173 |
|
| 174 |
If the compile fails, see *note compilation-problems::, for help. |
| 175 |
|
| 176 |
8. Install the distribution: |
| 177 |
|
| 178 |
shell> make install |
| 179 |
|
| 180 |
You might need to run this command as `root'. |
| 181 |
|
| 182 |
If you want to set up an option file, use one of those present in |
| 183 |
the `support-files' directory as a template. For example: |
| 184 |
|
| 185 |
shell> cp support-files/my-medium.cnf /etc/my.cnf |
| 186 |
|
| 187 |
You might need to run this command as `root'. |
| 188 |
|
| 189 |
If you want to configure support for `InnoDB' tables, you should |
| 190 |
edit the `/etc/my.cnf' file, remove the `#' character before the |
| 191 |
option lines that start with `innodb_...', and modify the option |
| 192 |
values to be what you want. See *note option-files::, and *note |
| 193 |
innodb-configuration::. |
| 194 |
|
| 195 |
9. Change location into the installation directory: |
| 196 |
|
| 197 |
shell> cd /usr/local/mysql |
| 198 |
|
| 199 |
10. If you ran the `make install' command as `root', the installed |
| 200 |
files will be owned by `root'. Ensure that the installation is |
| 201 |
accessible to `mysql' by executing the following commands as |
| 202 |
`root' in the installation directory: |
| 203 |
|
| 204 |
shell> chown -R mysql . |
| 205 |
shell> chgrp -R mysql . |
| 206 |
|
| 207 |
The first command changes the owner attribute of the files to the |
| 208 |
`mysql' user. The second changes the group attribute to the |
| 209 |
`mysql' group. |
| 210 |
|
| 211 |
11. If you have not installed MySQL before, you must create the MySQL |
| 212 |
data directory and initialize the grant tables: |
| 213 |
|
| 214 |
shell> bin/mysql_install_db --user=mysql |
| 215 |
|
| 216 |
If you run the command as `root', include the `--user' option as |
| 217 |
shown. If you run the command while logged in as `mysql', you can |
| 218 |
omit the `--user' option. |
| 219 |
|
| 220 |
The command should create the data directory and its contents with |
| 221 |
`mysql' as the owner. |
| 222 |
|
| 223 |
After using `mysql_install_db' to create the grant tables for |
| 224 |
MySQL, you must restart the server manually. The `mysqld_safe' |
| 225 |
command to do this is shown in a later step. |
| 226 |
|
| 227 |
12. Most of the MySQL installation can be owned by `root' if you like. |
| 228 |
The exception is that the data directory must be owned by `mysql'. |
| 229 |
To accomplish this, run the following commands as `root' in the |
| 230 |
installation directory: |
| 231 |
|
| 232 |
shell> chown -R root . |
| 233 |
shell> chown -R mysql var |
| 234 |
|
| 235 |
13. If you want MySQL to start automatically when you boot your |
| 236 |
machine, you can copy `support-files/mysql.server' to the location |
| 237 |
where your system has its startup files. More information can be |
| 238 |
found in the `support-files/mysql.server' script itself; see also |
| 239 |
*note automatic-start::. |
| 240 |
|
| 241 |
14. You can set up new accounts using the `bin/mysql_setpermission' |
| 242 |
script if you install the `DBI' and `DBD::mysql' Perl modules. See |
| 243 |
*note mysql-setpermission::. For Perl module installation |
| 244 |
instructions, see *note perl-support::. |
| 245 |
|
| 246 |
After everything has been installed, you should test your distribution. |
| 247 |
To start the MySQL server, use the following command: |
| 248 |
|
| 249 |
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql & |
| 250 |
|
| 251 |
If you run the command as `root', you should use the `--user' option as |
| 252 |
shown. The value of the option is the name of the login account that |
| 253 |
you created in the first step to use for running the server. If you run |
| 254 |
the command while logged in as that user, you can omit the `--user' |
| 255 |
option. |
| 256 |
|
| 257 |
If the command fails immediately and prints `mysqld ended', you can |
| 258 |
find some information in the `HOST_NAME.err' file in the data directory. |
| 259 |
|
| 260 |
More information about `mysqld_safe' is given in *note mysqld-safe::. |
| 261 |
|
| 262 |
*Note*: |
| 263 |
|
| 264 |
The accounts that are listed in the MySQL grant tables initially have |
| 265 |
no passwords. After starting the server, you should set up passwords |
| 266 |
for them using the instructions in *note post-installation::. |
| 267 |
|
| 268 |
File: manual.info, Node: configure-options, Next: installing-source-tree, Prev: quick-install, Up: installing-source |
| 269 |
|
| 270 |
2.4.15.2 Typical `configure' Options |
| 271 |
.................................... |
| 272 |
|
| 273 |
This section does not apply to MySQL Enterprise Server users. |
| 274 |
|
| 275 |
The `configure' script gives you a great deal of control over how you |
| 276 |
configure a MySQL source distribution. Typically you do this using |
| 277 |
options on the `configure' command line. You can also affect |
| 278 |
`configure' using certain environment variables. See *note |
| 279 |
environment-variables::. For a full list of options supported by |
| 280 |
`configure', run this command: |
| 281 |
|
| 282 |
shell> ./configure --help |
| 283 |
|
| 284 |
Some of the `configure' options available are described here: |
| 285 |
|
| 286 |
* To compile just the MySQL client libraries and client programs and |
| 287 |
not the server, use the `--without-server' option: |
| 288 |
|
| 289 |
shell> ./configure --without-server |
| 290 |
|
| 291 |
If you have no C++ compiler, some client programs such as `mysql' |
| 292 |
cannot be compiled because they require C++.. In this case, you |
| 293 |
can remove the code in `configure' that tests for the C++ compiler |
| 294 |
and then run `./configure' with the `--without-server' option. The |
| 295 |
compile step should still try to build all clients, but you can |
| 296 |
ignore any warnings about files such as `mysql.cc'. (If `make' |
| 297 |
stops, try `make -k' to tell it to continue with the rest of the |
| 298 |
build even if errors occur.) |
| 299 |
|
| 300 |
* If you want to build the embedded MySQL library (`libmysqld.a'), |
| 301 |
use the `--with-embedded-server' option. |
| 302 |
|
| 303 |
* If you don't want your log files and database directories located |
| 304 |
under `/usr/local/var', use a `configure' command something like |
| 305 |
one of these: |
| 306 |
|
| 307 |
shell> ./configure --prefix=/usr/local/mysql |
| 308 |
shell> ./configure --prefix=/usr/local \ |
| 309 |
--localstatedir=/usr/local/mysql/data |
| 310 |
|
| 311 |
The first command changes the installation prefix so that |
| 312 |
everything is installed under `/usr/local/mysql' rather than the |
| 313 |
default of `/usr/local'. The second command preserves the default |
| 314 |
installation prefix, but overrides the default location for |
| 315 |
database directories (normally `/usr/local/var') and changes it to |
| 316 |
`/usr/local/mysql/data'. |
| 317 |
|
| 318 |
You can also specify the installation directory and data directory |
| 319 |
locations at server startup time by using the `--basedir' and |
| 320 |
`--datadir' options. These can be given on the command line or in |
| 321 |
an MySQL option file, although it is more common to use an option |
| 322 |
file. See *note option-files::. |
| 323 |
|
| 324 |
* If you are using Unix and you want the MySQL socket file location |
| 325 |
to be somewhere other than the default location (normally in the |
| 326 |
directory `/tmp' or `/var/run'), use a `configure' command like |
| 327 |
this: |
| 328 |
|
| 329 |
shell> ./configure \ |
| 330 |
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock |
| 331 |
|
| 332 |
The socket filename must be an absolute pathname. You can also |
| 333 |
change the location of `mysql.sock' at server startup by using a |
| 334 |
MySQL option file. See *note problems-with-mysql-sock::. |
| 335 |
|
| 336 |
* If you want to compile statically linked programs (for example, to |
| 337 |
make a binary distribution, to get better performance, or to work |
| 338 |
around problems with some Red Hat Linux distributions), run |
| 339 |
`configure' like this: |
| 340 |
|
| 341 |
shell> ./configure --with-client-ldflags=-all-static \ |
| 342 |
--with-mysqld-ldflags=-all-static |
| 343 |
|
| 344 |
* If you are using `gcc' and don't have `libg++' or `libstdc++' |
| 345 |
installed, you can tell `configure' to use `gcc' as your C++ |
| 346 |
compiler: |
| 347 |
|
| 348 |
shell> CC=gcc CXX=gcc ./configure |
| 349 |
|
| 350 |
When you use `gcc' as your C++ compiler, it does not attempt to |
| 351 |
link in `libg++' or `libstdc++'. This may be a good thing to do |
| 352 |
even if you have those libraries installed. Some versions of them |
| 353 |
have caused strange problems for MySQL users in the past. |
| 354 |
|
| 355 |
The following list indicates some compilers and environment |
| 356 |
variable settings that are commonly used with each one. |
| 357 |
|
| 358 |
* `gcc' 2.7.2: |
| 359 |
|
| 360 |
CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors" |
| 361 |
|
| 362 |
* `gcc' 2.95.2: |
| 363 |
|
| 364 |
CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro \ |
| 365 |
-felide-constructors -fno-exceptions -fno-rtti" |
| 366 |
|
| 367 |
* `pgcc' 2.90.29 or newer: |
| 368 |
|
| 369 |
CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc \ |
| 370 |
CXXFLAGS="-O3 -mpentiumpro -mstack-align-double \ |
| 371 |
-felide-constructors -fno-exceptions -fno-rtti" |
| 372 |
|
| 373 |
In most cases, you can get a reasonably optimized MySQL binary by |
| 374 |
using the options from the preceding list and adding the following |
| 375 |
options to the `configure' line: |
| 376 |
|
| 377 |
--prefix=/usr/local/mysql --enable-assembler \ |
| 378 |
--with-mysqld-ldflags=-all-static |
| 379 |
|
| 380 |
The full `configure' line would, in other words, be something like |
| 381 |
the following for all recent `gcc' versions: |
| 382 |
|
| 383 |
CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro \ |
| 384 |
-felide-constructors -fno-exceptions -fno-rtti" ./configure \ |
| 385 |
--prefix=/usr/local/mysql --enable-assembler \ |
| 386 |
--with-mysqld-ldflags=-all-static |
| 387 |
|
| 388 |
The binaries we provide on the MySQL Web site at |
| 389 |
`http://dev.mysql.com/downloads/' are all compiled with full |
| 390 |
optimization and should be perfect for most users. See *note |
| 391 |
mysql-binaries::. There are some configuration settings you can |
| 392 |
tweak to build an even faster binary, but these are only for |
| 393 |
advanced users. See *note compile-and-link-options::. |
| 394 |
|
| 395 |
If the build fails and produces errors about your compiler or |
| 396 |
linker not being able to create the shared library |
| 397 |
`libmysqlclient.so.N' (where N is a version number), you can work |
| 398 |
around this problem by giving the `--disable-shared' option to |
| 399 |
`configure'. In this case, `configure' does not build a shared |
| 400 |
`libmysqlclient.so.N' library. |
| 401 |
|
| 402 |
* By default, MySQL uses the `latin1' (cp1252 West European) |
| 403 |
character set. To change the default set, use the `--with-charset' |
| 404 |
option: |
| 405 |
|
| 406 |
shell> ./configure --with-charset=CHARSET |
| 407 |
|
| 408 |
CHARSET may be one of `binary', `armscii8', `ascii', `big5', |
| 409 |
`cp1250', `cp1251', `cp1256', `cp1257', `cp850', `cp852', `cp866', |
| 410 |
`cp932', `dec8', `eucjpms', `euckr', `gb2312', `gbk', `geostd8', |
| 411 |
`greek', `hebrew', `hp8', `keybcs2', `koi8r', `koi8u', `latin1', |
| 412 |
`latin2', `latin5', `latin7', `macce', `macroman', `sjis', `swe7', |
| 413 |
`tis620', `ucs2', `ujis', `utf8'. See *note |
| 414 |
charset-configuration::. (Additional character sets might be |
| 415 |
available. Check the output from `./configure --help' for the |
| 416 |
current list.) |
| 417 |
|
| 418 |
The default collation may also be specified. MySQL uses the |
| 419 |
`latin1_swedish_ci' collation by default. To change this, use the |
| 420 |
`--with-collation' option: |
| 421 |
|
| 422 |
shell> ./configure --with-collation=COLLATION |
| 423 |
|
| 424 |
To change both the character set and the collation, use both the |
| 425 |
`--with-charset' and `--with-collation' options. The collation |
| 426 |
must be a legal collation for the character set. (Use the `SHOW |
| 427 |
COLLATION' statement to determine which collations are available |
| 428 |
for each character set.) |
| 429 |
|
| 430 |
*Warning*: |
| 431 |
|
| 432 |
If you change character sets after having created any tables, you |
| 433 |
must run `myisamchk -r -q --set-collation=COLLATION_NAME' _on |
| 434 |
every `MyISAM' table_. Your indexes may be sorted incorrectly |
| 435 |
otherwise. This can happen if you install MySQL, create some |
| 436 |
tables, and then reconfigure MySQL to use a different character |
| 437 |
set and reinstall it. |
| 438 |
|
| 439 |
With the `configure' option `--with-extra-charsets=LIST', you can |
| 440 |
define which additional character sets should be compiled into the |
| 441 |
server. LIST is one of the following: |
| 442 |
|
| 443 |
* A list of character set names separated by spaces |
| 444 |
|
| 445 |
* `complex' to include all character sets that can't be |
| 446 |
dynamically loaded |
| 447 |
|
| 448 |
* `all' to include all character sets into the binaries |
| 449 |
|
| 450 |
Clients that want to convert characters between the server and the |
| 451 |
client should use the `SET NAMES' statement. See *note |
| 452 |
set-option::, and *note charset-connection::. |
| 453 |
|
| 454 |
* To configure MySQL with debugging code, use the `--with-debug' |
| 455 |
option: |
| 456 |
|
| 457 |
shell> ./configure --with-debug |
| 458 |
|
| 459 |
This causes a safe memory allocator to be included that can find |
| 460 |
some errors and that provides output about what is happening. See |
| 461 |
MySQL Internals: Porting |
| 462 |
(http://forge.mysql.com/wiki/MySQL_Internals_Porting). |
| 463 |
|
| 464 |
As of MySQL 5.0.25, using `--with-debug' to configure MySQL with |
| 465 |
debugging support enables you to use the |
| 466 |
`--debug="d,parser_debug"' option when you start the server. This |
| 467 |
causes the Bison parser that is used to process SQL statements to |
| 468 |
dump a parser trace to the server's standard error output. |
| 469 |
Typically, this output is written to the error log. |
| 470 |
|
| 471 |
* If your client programs are using threads, you must compile a |
| 472 |
thread-safe version of the MySQL client library with the |
| 473 |
`--enable-thread-safe-client' configure option. This creates a |
| 474 |
`libmysqlclient_r' library with which you should link your threaded |
| 475 |
applications. See *note threaded-clients::. |
| 476 |
|
| 477 |
* It is possible to build MySQL 5.0 with large table support using |
| 478 |
the `--with-big-tables' option, beginning with MySQL 5.0.4. |
| 479 |
|
| 480 |
This option causes the variables that store table row counts to be |
| 481 |
declared as `unsigned long long' rather than `unsigned long'. This |
| 482 |
enables tables to hold up to approximately 1.844E+19 ((2^32)^2) |
| 483 |
rows rather than 2^32 (~4.295E+09) rows. Previously it was |
| 484 |
necessary to pass `-DBIG_TABLES' to the compiler manually in order |
| 485 |
to enable this feature. |
| 486 |
|
| 487 |
* Run `configure' with the `--disable-grant-options' option to cause |
| 488 |
the the `--bootstrap', `--skip-grant-tables', and `--init-file' |
| 489 |
options for `mysqld' to be disabled. For Windows, the |
| 490 |
`configure.js' script recognizes the `DISABLE_GRANT_OPTIONS' flag, |
| 491 |
which has the same effect. The capability is available as of MySQL |
| 492 |
5.0.34. |
| 493 |
|
| 494 |
* See *note operating-system-specific-notes::, for options that |
| 495 |
pertain to particular operating systems. |
| 496 |
|
| 497 |
* See *note secure-using-ssl::, for options that pertain to |
| 498 |
configuring MySQL to support secure (encrypted) connections. |
| 499 |
|
| 500 |
File: manual.info, Node: installing-source-tree, Next: compilation-problems, Prev: configure-options, Up: installing-source |
| 501 |
|
| 502 |
2.4.15.3 Installing from the Development Source Tree |
| 503 |
.................................................... |
| 504 |
|
| 505 |
This section does not apply to MySQL Enterprise Server users. |
| 506 |
|
| 507 |
*Caution*: |
| 508 |
|
| 509 |
You should read this section only if you are interested in helping us |
| 510 |
test our new code. If you just want to get MySQL up and running on your |
| 511 |
system, you should use a standard release distribution (either a binary |
| 512 |
or source distribution). |
| 513 |
|
| 514 |
To obtain our most recent development source tree, first download and |
| 515 |
install the BitKeeper free client if you do not have it. The client can |
| 516 |
be obtained from `http://www.bitmover.com/bk-client2.0.shar'. Note that |
| 517 |
you will need `gcc' and `make' to build the BitKeeper free client, and |
| 518 |
`patch' and `tar' to use the BitKeeper free client. _Note that old 1.1 |
| 519 |
versions of the BitKeeper free client will not work!_ |
| 520 |
|
| 521 |
To install the BitKeeper client on Unix, use these commands: |
| 522 |
|
| 523 |
shell> /bin/sh bk-client2.0.shar |
| 524 |
shell> cd bk-client2.0 |
| 525 |
shell> make |
| 526 |
|
| 527 |
If you get a `cc: command not found' error, invoke this command before |
| 528 |
running `make': |
| 529 |
|
| 530 |
shell> make CC=gcc |
| 531 |
|
| 532 |
The step above will create the utility `bkf', which is the free |
| 533 |
BitKeeper client. |
| 534 |
|
| 535 |
To install the BitKeeper client on Windows, use these instructions: |
| 536 |
|
| 537 |
1. Download and install Cygwin from http://cygwin.com |
| 538 |
(http://cygwin.com/). |
| 539 |
|
| 540 |
2. Make sure `patch', `tar', `gcc' and `make' have been installed |
| 541 |
under Cygwin. You can test this by issuing `which GCC' for each |
| 542 |
command. If a required tool is not installed, run Cygwin's package |
| 543 |
manager, select the required tools and install them. |
| 544 |
|
| 545 |
3. For the installation of the BitKeeper free client, use the same |
| 546 |
installations as given for Unix-like systems above. |
| 547 |
|
| 548 |
For more information on `bkf', use: |
| 549 |
|
| 550 |
shell> bkf --help |
| 551 |
|
| 552 |
After you have installed the BitKeeper client, you can access the MySQL |
| 553 |
development source tree: |
| 554 |
|
| 555 |
1. Change location to the directory you want to work from, and then |
| 556 |
use the following command to make a local copy of the MySQL 5.0 |
| 557 |
branch: |
| 558 |
|
| 559 |
shell> bkf clone bk://mysql.bkbits.net/mysql-5.0 mysql-5.0 |
| 560 |
|
| 561 |
In the preceding example, the source tree is set up in the |
| 562 |
`mysql-5.0/' subdirectory of your current directory. |
| 563 |
|
| 564 |
The initial download of the source tree may take a while, |
| 565 |
depending on the speed of your connection. Please be patient. |
| 566 |
|
| 567 |
2. You need GNU `make', `autoconf' 2.58 (or newer), `automake' 1.8.1, |
| 568 |
`libtool' 1.5, and `m4' to run the next set of commands. Even |
| 569 |
though many operating systems come with their own implementation of |
| 570 |
`make', chances are high that the compilation fails with strange |
| 571 |
error messages. Therefore, it is highly recommended that you use |
| 572 |
GNU `make' (sometimes named `gmake') instead. |
| 573 |
|
| 574 |
Fortunately, a large number of operating systems ship with the GNU |
| 575 |
toolchain preinstalled or supply installable packages of these. In |
| 576 |
any case, they can also be downloaded from the following locations: |
| 577 |
|
| 578 |
* `http://www.gnu.org/software/autoconf/' |
| 579 |
|
| 580 |
* `http://www.gnu.org/software/automake/' |
| 581 |
|
| 582 |
* `http://www.gnu.org/software/libtool/' |
| 583 |
|
| 584 |
* `http://www.gnu.org/software/m4/' |
| 585 |
|
| 586 |
* `http://www.gnu.org/software/make/' |
| 587 |
|
| 588 |
To configure MySQL 5.0, you also need GNU `bison'. You should use |
| 589 |
the latest version of bison where possible. Version 1.75 and |
| 590 |
version 2.1 are known to work. There have been reported problems |
| 591 |
with `bison' 1.875. If you experience problems, upgrade to a |
| 592 |
later, rather than earlier, version. Versions of `bison' older |
| 593 |
than 1.75 may report this error: |
| 594 |
|
| 595 |
sql_yacc.yy:#####: fatal error: maximum table size (32767) exceeded |
| 596 |
|
| 597 |
Note: The maximum table size is not actually exceeded; the error |
| 598 |
is caused by bugs in older versions of `bison'. |
| 599 |
|
| 600 |
The following example shows the typical commands required to |
| 601 |
configure a source tree. The first `cd' command changes location |
| 602 |
into the top-level directory of the tree; replace `mysql-5.0' with |
| 603 |
the appropriate directory name. |
| 604 |
|
| 605 |
shell> cd mysql-5.0 |
| 606 |
shell> (cd bdb/dist; sh s_all) |
| 607 |
shell> (cd innobase; autoreconf --force --install) |
| 608 |
shell> autoreconf --force --install |
| 609 |
shell> ./configure # Add your favorite options here |
| 610 |
shell> make |
| 611 |
|
| 612 |
Or you can use `BUILD/autorun.sh' as a shortcut for the following |
| 613 |
sequence of commands: |
| 614 |
|
| 615 |
shell> aclocal; autoheader |
| 616 |
shell> libtoolize --automake --force |
| 617 |
shell> automake --force --add-missing; autoconf |
| 618 |
shell> (cd innobase; aclocal; autoheader; autoconf; automake) |
| 619 |
shell> (cd bdb/dist; sh s_all) |
| 620 |
|
| 621 |
The command lines that change directory into the `innobase' and |
| 622 |
`bdb/dist' directories are used to configure the `InnoDB' and |
| 623 |
Berkeley DB (`BDB') storage engines. You can omit these command |
| 624 |
lines if you to not require `InnoDB' or `BDB' support. |
| 625 |
|
| 626 |
If you get some strange errors during this stage, verify that you |
| 627 |
really have `libtool' installed. |
| 628 |
|
| 629 |
A collection of our standard configuration scripts is located in |
| 630 |
the `BUILD/' subdirectory. You may find it more convenient to use |
| 631 |
the `BUILD/compile-pentium-debug' script than the preceding set of |
| 632 |
shell commands. To compile on a different architecture, modify the |
| 633 |
script by removing flags that are Pentium-specific. |
| 634 |
|
| 635 |
3. When the build is done, run `make install'. Be careful with this |
| 636 |
on a production machine; the command may overwrite your live |
| 637 |
release installation. If you have another installation of MySQL, |
| 638 |
we recommend that you run `./configure' with different values for |
| 639 |
the `--prefix', `--with-tcp-port', and `--unix-socket-path' |
| 640 |
options than those used for your production server. |
| 641 |
|
| 642 |
4. Play hard with your new installation and try to make the new |
| 643 |
features crash. Start by running `make test'. See *note |
| 644 |
mysql-test-suite::. |
| 645 |
|
| 646 |
5. If you have gotten to the `make' stage, but the distribution does |
| 647 |
not compile, please enter the problem into our bugs database using |
| 648 |
the instructions given in *note bug-reports::. If you have |
| 649 |
installed the latest versions of the required GNU tools, and they |
| 650 |
crash trying to process our configuration files, please report |
| 651 |
that also. However, if you execute `aclocal' and get a `command not |
| 652 |
found' error or a similar problem, do not report it. Instead, make |
| 653 |
sure that all the necessary tools are installed and that your |
| 654 |
`PATH' variable is set correctly so that your shell can find them. |
| 655 |
|
| 656 |
6. After initially copying the repository with `bkf' to obtain the |
| 657 |
source tree, you should use `pull' option to periodically update |
| 658 |
your local copy. To do this any time after you have set up the |
| 659 |
repository, use this command: |
| 660 |
|
| 661 |
shell> bkf pull |
| 662 |
|
| 663 |
7. You can examine the changeset comments for the tree by using the |
| 664 |
`changes' option to `bkf': |
| 665 |
|
| 666 |
shell> bkf changes |
| 667 |
|
| 668 |
To get a list of the changes that would be applied with the next |
| 669 |
`bkf pull': |
| 670 |
|
| 671 |
shell> bkf changes -R |
| 672 |
|
| 673 |
To obtain a patch file for a specific changeset (`CSETID'), use: |
| 674 |
|
| 675 |
shell> bkf changes -vvrCSETID |
| 676 |
|
| 677 |
If you see diffs or code that you have a question about, do not |
| 678 |
hesitate to send email to the MySQL Internals mailing list. (See |
| 679 |
*note mailing-lists::.) Also, if you think you have a better idea |
| 680 |
on how to do something, send an email message to the list with |
| 681 |
your proposed patch. |
| 682 |
|
| 683 |
You can also browse changesets, comments, and source code online. To |
| 684 |
browse this information for MySQL 5.0, go to |
| 685 |
`http://mysql.bkbits.net:8080/mysql-5.0'. |
| 686 |
|
| 687 |
File: manual.info, Node: compilation-problems, Next: mit-pthreads, Prev: installing-source-tree, Up: installing-source |
| 688 |
|
| 689 |
2.4.15.4 Dealing with Problems Compiling MySQL |
| 690 |
.............................................. |
| 691 |
|
| 692 |
This section does not apply to MySQL Enterprise Server users. |
| 693 |
|
| 694 |
All MySQL programs compile cleanly for us with no warnings on Solaris |
| 695 |
or Linux using `gcc'. On other systems, warnings may occur due to |
| 696 |
differences in system include files. See *note mit-pthreads::, for |
| 697 |
warnings that may occur when using MIT-pthreads. For other problems, |
| 698 |
check the following list. |
| 699 |
|
| 700 |
The solution to many problems involves reconfiguring. If you do need to |
| 701 |
reconfigure, take note of the following: |
| 702 |
|
| 703 |
* If `configure' is run after it has previously been run, it may use |
| 704 |
information that was gathered during its previous invocation. This |
| 705 |
information is stored in `config.cache'. When `configure' starts |
| 706 |
up, it looks for that file and reads its contents if it exists, on |
| 707 |
the assumption that the information is still correct. That |
| 708 |
assumption is invalid when you reconfigure. |
| 709 |
|
| 710 |
* Each time you run `configure', you must run `make' again to |
| 711 |
recompile. However, you may want to remove old object files from |
| 712 |
previous builds first because they were compiled using different |
| 713 |
configuration options. |
| 714 |
|
| 715 |
To prevent old configuration information or object files from being |
| 716 |
used, run these commands before re-running `configure': |
| 717 |
|
| 718 |
shell> rm config.cache |
| 719 |
shell> make clean |
| 720 |
|
| 721 |
Alternatively, you can run `make distclean'. |
| 722 |
|
| 723 |
The following list describes some of the problems when compiling MySQL |
| 724 |
that have been found to occur most often: |
| 725 |
|
| 726 |
* If you get errors such as the ones shown here when compiling |
| 727 |
`sql_yacc.cc', you probably have run out of memory or swap space: |
| 728 |
|
| 729 |
Internal compiler error: program cc1plus got fatal signal 11 |
| 730 |
Out of virtual memory |
| 731 |
Virtual memory exhausted |
| 732 |
|
| 733 |
The problem is that `gcc' requires a huge amount of memory to |
| 734 |
compile `sql_yacc.cc' with inline functions. Try running |
| 735 |
`configure' with the `--with-low-memory' option: |
| 736 |
|
| 737 |
shell> ./configure --with-low-memory |
| 738 |
|
| 739 |
This option causes `-fno-inline' to be added to the compile line |
| 740 |
if you are using `gcc' and `-O0' if you are using something else. |
| 741 |
You should try the `--with-low-memory' option even if you have so |
| 742 |
much memory and swap space that you think you can't possibly have |
| 743 |
run out. This problem has been observed to occur even on systems |
| 744 |
with generous hardware configurations, and the `--with-low-memory' |
| 745 |
option usually fixes it. |
| 746 |
|
| 747 |
* By default, `configure' picks `c++' as the compiler name and GNU |
| 748 |
`c++' links with `-lg++'. If you are using `gcc', that behavior can |
| 749 |
cause problems during configuration such as this: |
| 750 |
|
| 751 |
configure: error: installation or configuration problem: |
| 752 |
C++ compiler cannot create executables. |
| 753 |
|
| 754 |
You might also observe problems during compilation related to |
| 755 |
`g++', `libg++', or `libstdc++'. |
| 756 |
|
| 757 |
One cause of these problems is that you may not have `g++', or you |
| 758 |
may have `g++' but not `libg++', or `libstdc++'. Take a look at the |
| 759 |
`config.log' file. It should contain the exact reason why your C++ |
| 760 |
compiler didn't work. To work around these problems, you can use |
| 761 |
`gcc' as your C++ compiler. Try setting the environment variable |
| 762 |
`CXX' to `"gcc -O3"'. For example: |
| 763 |
|
| 764 |
shell> CXX="gcc -O3" ./configure |
| 765 |
|
| 766 |
This works because `gcc' compiles C++ source files as well as |
| 767 |
`g++' does, but does not link in `libg++' or `libstdc++' by |
| 768 |
default. |
| 769 |
|
| 770 |
Another way to fix these problems is to install `g++', `libg++', |
| 771 |
and `libstdc++'. However, we recommend that you not use `libg++' or |
| 772 |
`libstdc++' with MySQL because this only increases the binary size |
| 773 |
of `mysqld' without providing any benefits. Some versions of these |
| 774 |
libraries have also caused strange problems for MySQL users in the |
| 775 |
past. |
| 776 |
|
| 777 |
* If your compile fails with errors such as any of the following, |
| 778 |
you must upgrade your version of `make' to GNU `make': |
| 779 |
|
| 780 |
making all in mit-pthreads |
| 781 |
make: Fatal error in reader: Makefile, line 18: |
| 782 |
Badly formed macro assignment |
| 783 |
|
| 784 |
Or: |
| 785 |
|
| 786 |
make: file `Makefile' line 18: Must be a separator (: |
| 787 |
|
| 788 |
Or: |
| 789 |
|
| 790 |
pthread.h: No such file or directory |
| 791 |
|
| 792 |
Solaris and FreeBSD are known to have troublesome `make' programs. |
| 793 |
|
| 794 |
GNU `make' 3.75 is known to work. |
| 795 |
|
| 796 |
* If you want to define flags to be used by your C or C++ compilers, |
| 797 |
do so by adding the flags to the `CFLAGS' and `CXXFLAGS' |
| 798 |
environment variables. You can also specify the compiler names |
| 799 |
this way using `CC' and `CXX'. For example: |
| 800 |
|
| 801 |
shell> CC=gcc |
| 802 |
shell> CFLAGS=-O3 |
| 803 |
shell> CXX=gcc |
| 804 |
shell> CXXFLAGS=-O3 |
| 805 |
shell> export CC CFLAGS CXX CXXFLAGS |
| 806 |
|
| 807 |
See *note mysql-binaries::, for a list of flag definitions that |
| 808 |
have been found to be useful on various systems. |
| 809 |
|
| 810 |
* If you get errors such as those shown here when compiling |
| 811 |
`mysqld', `configure' did not correctly detect the type of the |
| 812 |
last argument to `accept()', `getsockname()', or `getpeername()': |
| 813 |
|
| 814 |
cxx: Error: mysqld.cc, line 645: In this statement, the referenced |
| 815 |
type of the pointer value ''length'' is ''unsigned long'', |
| 816 |
which is not compatible with ''int''. |
| 817 |
new_sock = accept(sock, (struct sockaddr *)&cAddr, &length); |
| 818 |
|
| 819 |
To fix this, edit the `config.h' file (which is generated by |
| 820 |
`configure'). Look for these lines: |
| 821 |
|
| 822 |
/* Define as the base type of the last arg to accept */ |
| 823 |
#define SOCKET_SIZE_TYPE XXX |
| 824 |
|
| 825 |
Change `XXX' to `size_t' or `int', depending on your operating |
| 826 |
system. (You must do this each time you run `configure' because |
| 827 |
`configure' regenerates `config.h'.) |
| 828 |
|
| 829 |
* The `sql_yacc.cc' file is generated from `sql_yacc.yy'. Normally, |
| 830 |
the build process does not need to create `sql_yacc.cc' because |
| 831 |
MySQL comes with a pre-generated copy. However, if you do need to |
| 832 |
re-create it, you might encounter this error: |
| 833 |
|
| 834 |
"sql_yacc.yy", line XXX fatal: default action causes potential... |
| 835 |
|
| 836 |
This is a sign that your version of `yacc' is deficient. You |
| 837 |
probably need to install `bison' (the GNU version of `yacc') and |
| 838 |
use that instead. |
| 839 |
|
| 840 |
* On Debian Linux 3.0, you need to install `gawk' instead of the |
| 841 |
default `mawk' if you want to compile MySQL with Berkeley DB |
| 842 |
support. |
| 843 |
|
| 844 |
* If you need to debug `mysqld' or a MySQL client, run `configure' |
| 845 |
with the `--with-debug' option, and then recompile and link your |
| 846 |
clients with the new client library. See MySQL Internals: Porting |
| 847 |
(http://forge.mysql.com/wiki/MySQL_Internals_Porting). |
| 848 |
|
| 849 |
* If you get a compilation error on Linux (for example, SuSE Linux |
| 850 |
8.1 or Red Hat Linux 7.3) similar to the following one, you |
| 851 |
probably do not have `g++' installed: |
| 852 |
|
| 853 |
libmysql.c:1329: warning: passing arg 5 of `gethostbyname_r' from |
| 854 |
incompatible pointer type |
| 855 |
libmysql.c:1329: too few arguments to function `gethostbyname_r' |
| 856 |
libmysql.c:1329: warning: assignment makes pointer from integer |
| 857 |
without a cast |
| 858 |
make[2]: *** [libmysql.lo] Error 1 |
| 859 |
|
| 860 |
By default, the `configure' script attempts to determine the |
| 861 |
correct number of arguments by using `g++' (the GNU C++ compiler). |
| 862 |
This test yields incorrect results if `g++' is not installed. |
| 863 |
There are two ways to work around this problem: |
| 864 |
|
| 865 |
* Make sure that the GNU C++ `g++' is installed. On some Linux |
| 866 |
distributions, the required package is called `gpp'; on |
| 867 |
others, it is named `gcc-c++'. |
| 868 |
|
| 869 |
* Use `gcc' as your C++ compiler by setting the `CXX' |
| 870 |
environment variable to `gcc': |
| 871 |
|
| 872 |
export CXX="gcc" |
| 873 |
|
| 874 |
You must run `configure' again after making either of those |
| 875 |
changes. |
| 876 |
|
| 877 |
File: manual.info, Node: mit-pthreads, Next: windows-source-build, Prev: compilation-problems, Up: installing-source |
| 878 |
|
| 879 |
2.4.15.5 MIT-pthreads Notes |
| 880 |
........................... |
| 881 |
|
| 882 |
This section does not apply to MySQL Enterprise Server users. |
| 883 |
|
| 884 |
This section describes some of the issues involved in using |
| 885 |
MIT-pthreads. |
| 886 |
|
| 887 |
On Linux, you should _not_ use MIT-pthreads. Use the installed |
| 888 |
LinuxThreads implementation instead. See *note linux::. |
| 889 |
|
| 890 |
If your system does not provide native thread support, you should build |
| 891 |
MySQL using the MIT-pthreads package. This includes older FreeBSD |
| 892 |
systems, SunOS 4.x, Solaris 2.4 and earlier, and some others. See *note |
| 893 |
which-os::. |
| 894 |
|
| 895 |
MIT-pthreads is not part of the MySQL 5.0 source distribution. If you |
| 896 |
require this package, you need to download it separately from |
| 897 |
`http://dev.mysql.com/Downloads/Contrib/pthreads-1_60_beta6-mysql.tar.gz' |
| 898 |
|
| 899 |
After downloading, extract this source archive into the top level of |
| 900 |
the MySQL source directory. It creates a new subdirectory named |
| 901 |
`mit-pthreads'. |
| 902 |
|
| 903 |
* On most systems, you can force MIT-pthreads to be used by running |
| 904 |
`configure' with the `--with-mit-threads' option: |
| 905 |
|
| 906 |
shell> ./configure --with-mit-threads |
| 907 |
|
| 908 |
Building in a non-source directory is not supported when using |
| 909 |
MIT-pthreads because we want to minimize our changes to this code. |
| 910 |
|
| 911 |
* The checks that determine whether to use MIT-pthreads occur only |
| 912 |
during the part of the configuration process that deals with the |
| 913 |
server code. If you have configured the distribution using |
| 914 |
`--without-server' to build only the client code, clients do not |
| 915 |
know whether MIT-pthreads is being used and use Unix socket file |
| 916 |
connections by default. Because Unix socket files do not work |
| 917 |
under MIT-pthreads on some platforms, this means you need to use |
| 918 |
`-h' or `--host' with a value other than `localhost' when you run |
| 919 |
client programs. |
| 920 |
|
| 921 |
* When MySQL is compiled using MIT-pthreads, system locking is |
| 922 |
disabled by default for performance reasons. You can tell the |
| 923 |
server to use system locking with the `--external-locking' option. |
| 924 |
This is needed only if you want to be able to run two MySQL |
| 925 |
servers against the same data files, but that is not recommended, |
| 926 |
anyway. |
| 927 |
|
| 928 |
* Sometimes the pthread `bind()' command fails to bind to a socket |
| 929 |
without any error message (at least on Solaris). The result is |
| 930 |
that all connections to the server fail. For example: |
| 931 |
|
| 932 |
shell> mysqladmin version |
| 933 |
mysqladmin: connect to server at '' failed; |
| 934 |
error: 'Can't connect to mysql server on localhost (146)' |
| 935 |
|
| 936 |
The solution to this problem is to kill the `mysqld' server and |
| 937 |
restart it. This has happened to us only when we have forcibly |
| 938 |
stopped the server and restarted it immediately. |
| 939 |
|
| 940 |
* With MIT-pthreads, the `sleep()' system call isn't interruptible |
| 941 |
with `SIGINT' (break). This is noticeable only when you run |
| 942 |
`mysqladmin --sleep'. You must wait for the `sleep()' call to |
| 943 |
terminate before the interrupt is served and the process stops. |
| 944 |
|
| 945 |
* When linking, you might receive warning messages like these (at |
| 946 |
least on Solaris); they can be ignored: |
| 947 |
|
| 948 |
ld: warning: symbol `_iob' has differing sizes: |
| 949 |
(file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4; |
| 950 |
file /usr/lib/libc.so value=0x140); |
| 951 |
/my/local/pthreads/lib/libpthread.a(findfp.o) definition taken |
| 952 |
ld: warning: symbol `__iob' has differing sizes: |
| 953 |
(file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4; |
| 954 |
file /usr/lib/libc.so value=0x140); |
| 955 |
/my/local/pthreads/lib/libpthread.a(findfp.o) definition taken |
| 956 |
|
| 957 |
* Some other warnings also can be ignored: |
| 958 |
|
| 959 |
implicit declaration of function `int strtoll(...)' |
| 960 |
implicit declaration of function `int strtoul(...)' |
| 961 |
|
| 962 |
* We have not been able to make `readline' work with MIT-pthreads. |
| 963 |
(This is not necessary, but may be of interest to some.) |
| 964 |
|