This chapter describes how to obtain and install MySQL:
For a list of sites from which you can obtain MySQL, see Section 2.2.1.
To see which platforms are supported, see Section 2.2.2. Please note that not all supported systems are equally good for running MySQL on them. On some it is much more robust and efficient than others—see Section 2.2.2 for details.
Several versions of MySQL are available in both binary and source distributions. We also provide public access to our current source tree for those who want to see our most recent developments and help us test new code. To determine which version and type of distribution you should use, see Section 2.2.3. When in doubt, use the binary distribution.
Installation instructions for binary and source distributions are described in Section 2.2.7, and Section 2.3. Each set of instructions includes a section on system-specific problems you may run into.
For post-installation procedures, see Section 2.4. These procedures apply whether you install MySQL using a binary or source distribution.
The recommended way to install MySQL on Linux is by using an RPM file. The MySQL RPMs are currently being built on a RedHat Version 6.2 system but should work on other versions of Linux that support rpm and use glibc.
If you have problems with an RPM file, for example, if you receive the error "Sorry, the host 'xxxx' could not be looked up“—see Section 2.6.1.1.
The RPM files you may want to use are:
MySQL-VERSION.i386.rpm
The MySQL server. You will need this unless you only want to connect to a MySQL server running on another machine.
MySQL-client-VERSION.i386.rpm
The standard MySQL client programs. You probably always want to install this package.
MySQL-bench-VERSION.i386.rpm
Tests and benchmarks. Requires Perl and msql-mysql-modules RPMs.
MySQL-devel-VERSION.i386.rpm
Libraries and include files needed if you want to compile other MySQL clients, such as the Perl modules.
MySQL-VERSION.src.rpm
This contains the source code for all of the previous packages. It can also be used to try to build RPMs for other architectures (for example, Alpha or SPARC).
To see all files in an RPM package, run:
shell> rpm -qpl MySQL-VERSION.i386.rpm
To perform a standard minimal installation, run:
shell> rpm -i MySQL-VERSION.i386.rpm MySQL-client-VERSION.i386.rpm
To install just the client package, run:
shell> rpm -i MySQL-client-VERSION.i386.rpm
The RPM places data in /var/lib/mysql
. The RPM also creates the
appropriate entries in /etc/rc.d/
to start the server automatically
at boot time. (This means that if you have performed a previous
installation, you may want to make a copy of your previously installed
MySQL startup file if you made any changes to it, so you don’t lose
your changes.)
After installing the RPM file(s), the mysqld daemon should be running and you should now be able to start using MySQL. See Section 2.4.
If something goes wrong, you can find more information in the binary installation chapter. See Section 2.2.7.
The MySQL server for Windows is available in two distribution types:
The binary distribution contains a setup program which installs everything you need so that you can start the server immediately.
The source distribution contains all the code and support files for building the executables using the VC++ 6.0 compiler. See Section 2.3.7.
Generally speaking, you should use the binary distribution.
You will need the following:
A 32-bit Windows Operating System such as 9x, Me, NT, 2000, or XP. The NT family (NT, Windows 2000 and XP) permits running the MySQL server as a service. See Section 2.6.2.2.
If you want to use tables bigger than 4G, you should install MySQL on an NTFS or newer filesystem. Don’t forget to use MAX_ROWS and AVG_ROW_LENGTH when you create the table. See Section 6.5.3.
TCP/IP protocol support.
A copy of the MySQL binary or distribution for Windows, which can be downloaded from http://www.mysql.com/downloads/.
Note: The distribution files are supplied with a zipped format and we recommend the use of an adequate FTP client with resume feature to avoid corruption of files during the download process.
A ZIP program to unpack the distribution file.
Enough space on the hard drive to unpack, install, and create the databases in accorandance with your requirements.
If you plan to connect to the MySQL server via ODBC, you will also need the MyODBC driver. See Section 8.3.
If you are working on an NT/2000/XP server, logon as a user with with administrator privileges.
If you are doing an upgrade of an earlier MySQL installation, it is necessary to stop the server. If you are running the server as a service, use:
C:\> NET STOP MySQL
Otherwise, use:
C:\mysql\bin> mysqladmin -u root shutdown
On NT/2000/XP machines, if you want to change the server executable (e.g., -max or -nt), it is also necessary to remove the service:
C:\mysql\bin> mysqld-max-nt --remove
Unzip the distribution file to a temporary directory.
Run the
setup.exe
file to begin the installation process. If you want to install into another directory than the defaultc:\mysql
, use the Browse button to specify your preferred directory.Finish the install process.
Starting with MySQL 3.23.38, the Windows distribution includes both the normal and the MySQL-Max server binaries. Here is a list of the different MySQL servers you can use:
Binary |
Description |
---|---|
mysqld |
Compiled with full debugging and automatic memory allocation checking, symbolic links, InnoDB, and BDB tables. |
mysqld-opt |
Optimised binary with no support for transactional tables. |
mysqld-nt |
Optimised binary for NT/2000/XP with support for named pipes. You can run this version on Windows 9x/Me, but in this case no named pipes are created and you must have TCP/IP installed. |
mysqld-max |
Optimised binary with support for symbolic links, InnoDB and BDB tables. |
mysqld-max-nt |
Like mysqld-max, but compiled with support for named pipes. |
Starting from 3.23.50, named pipes are only enabled if one starts mysqld with --enable-named-pipe.
All of the preceding binaries are optimised for the Pentium Pro processor but should work on any Intel processor >= i386.
You will need to use an option file to specify your MySQL configuration under the following circumstances:
The installation or data directories are different from the default locations (
c:\mysql
andc:\mysql\data
).You want to use one of these servers:
mysqld.exe
mysqld-max.exe
mysqld-max-nt.exe
You need to tune the server settings.
Normally you can use the WinMySQLAdmin tool to edit the option file my.ini. In this case you don’t have to worry about the following section.
There are two option files with the same function: my.cnf
and
my.ini
. However, to avoid confusion, it’s best if you use only
of one them. Both files are plain text. The my.cnf
file, if used,
should be created in the root directory of the C drive. The my.ini
file, if used, should be created in the Windows system directory. (This
directory is typically something like C:\WINDOWS
or C:\WINNT
.
You can determine its exact location from the value of the windir
environment variable.) MySQL looks first for the my.ini file,
then for the my.cnf
file.
If your PC uses a boot loader where the C drive isn’t the boot drive,
your only option is to use the my.ini
file. Also note that
if you use the WinMySQLAdmin tool, it uses only the my.ini
file. The \mysql\bin
directory contains a help file with
instructions for using this tool.
Using notepad.exe, create the option file and edit the [mysqld] section to specify values for the basedir and datadir parameters:
[mysqld] # set basedir to installation path, e.g., c:/mysql basedir=the_install_path # set datadir to location of data directory, # e.g., c:/mysql/data or d:/mydata/data datadir=the_data_path
Note that Windows pathnames should be specified in option files using forward slashes rather than backslashes. If you do use backslashes, you must double them.
If you would like to use a data directory different from the default of
c:\mysql\data
, you must copy the entire contents of the
c:\mysql\data
directory to the new location.
If you want to use the InnoDB transactional tables, you
need to manually create two new directories to hold the InnoDB
data and log files—e.g., c:\ibdata
and c:\iblogs
.
You will also need to add some extra lines to the option
file. See Section 7.5.2.
If you don’t want to use InnoDB tables, add the skip-innodb option to the option file.
Now you are ready to test starting the server.
Testing from a DOS command prompt is the best thing to do because the server displays status messages that appear in the DOS window. If something is wrong with your configuration, these messages will make it easier for you to identify and fix any problems.
Make sure you are in the directory where the server is located, then enter this command:
C:\mysql\bin> mysqld-max --standalone
You should see the following messages as the server starts up:
InnoDB: The first specified data file c:\ibdata\ibdata1 did not exist: InnoDB: a new database to be created! InnoDB: Setting file c:\ibdata\ibdata1 size to 209715200 InnoDB: Database physically writes the file full: wait... InnoDB: Log file c:\iblogs\ib_logfile0 did not exist: new to be created InnoDB: Setting log file c:\iblogs\ib_logfile0 size to 31457280 InnoDB: Log file c:\iblogs\ib_logfile1 did not exist: new to be created InnoDB: Setting log file c:\iblogs\ib_logfile1 size to 31457280 InnoDB: Log file c:\iblogs\ib_logfile2 did not exist: new to be created InnoDB: Setting log file c:\iblogs\ib_logfile2 size to 31457280 InnoDB: Doublewrite buffer not found: creating new InnoDB: Doublewrite buffer created InnoDB: creating foreign key constraint system tables InnoDB: foreign key constraint system tables created 011024 10:58:25 InnoDB: Started
For further information about running MySQL on Windows, see Section 2.6.2.
Get MySQL Reference Manual now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.