This chapter covers the installation of MySQL on platforms where we offer packages using the native packaging format of the respective platform. However, binary distributions of MySQL are available for many other platforms as well, see Section 2.2.11, “Installing a MySQL Binary Distribution ” for generic installation instructions for these packages that apply to all platforms.
See Section 2.2, “General Installation Issues ” for more information on what other binary distributions are available on how to obtain them.
The MySQL server for Windows is available in two distribution formats:
The binary distribution contains a setup program that 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. Section 2.3.7, “Windows Source Distribution ”.
Generally speaking, you should use the binary distribution. It's simpler, and you need no additional tools to get MySQL up and running.
You will need the following:
A 32-bit Windows Operating System such as 9x, Me, NT, 2000, or XP. The NT family (Windows NT, 2000, and XP) permits you to run the MySQL server as a service. Section 2.6.1.2, “Starting MySQL on Windows NT, 2000, or XP ”.
If you need tables with a size larger than 4 GB, install MySQL on an NTFS or newer filesystem. Don't forget to use MAX_ROWS and AVG_ROW_LENGTH when you create tables. Section 6.5.3, “CREATE TABLE Syntax ”.
TCP/IP protocol support.
A copy of the MySQL binary 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 accordance with your requirements.
If you plan to connect to the MySQL server via ODBC, you will also need the MyODBC driver. Section 9.2, “MySQL ODBC Support ”.
If you are working on an NT/2000/XP server, log on as a user with administrator privileges.
If you are doing an upgrade of an earlier MySQL installation, it is necessary to stop the current server. If you are running the server as a service, stop it using this command:
C:\ NET STOP MySQL
Otherwise, stop the server like this:
C:\mysql\bin mysqladmin -u root shutdown
On NT/2000/XP machines, if you want to change the server executable (for example, -max or -nt), it is also necessary to remove the service:
C:\mysql\bin mysqld --remove
Exit the WinMySQLadmin program if it is running.
Unzip the distribution file to a temporary directory.
Run the setup.exe program to begin the installation process. If you want to install into another directory than the default (C:\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 from which you can choose:
| 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 in version 3.23. For version 4.0, InnoDB is enabled. |
| mysqld-nt | Optimised binary for NT/2000/XP with support for named pipes. |
| 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. |
All of the preceding binaries are optimised for modern Intel processors but should work on any Intel processor = i386.
When run on a version of Windows that supports named pipes (NT, 2000, XP), the mysqld-nt and mysqld-max-nt servers support named pipe connections. However, starting from 3.23.50, named pipes are enabled only if you start these servers with the -enable-named-pipe option. (The servers can be run on Windows 98 or Me, but TCP/IP must be installed, and named pipe connections cannot be used. On Windows 95, these servers cannot be used.)
You will find it helpful 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 and C:\mysql\data).
You need to tune the server settings. For example, if you want to use the InnoDB transactional tables in MySQL version 3.23, you need to manually create two new directories to hold the InnoDB data and log files--such as, C:\ibdata and C:\iblogs. You will also need to add some extra lines to the option file, as described in Section 7.5.3, “InnoDB Startup Options ”. (As of MySQL 4.0, InnoDB will create its datafiles and log files in the data directory by default. This means you need not configure InnoDB explicitly, though you may still wish to do so.)
On Windows, the MySQL installer places the data directory directly under the directory where you install MySQL. If you would like to use a data directory in a different location, you should copy the entire contents of the data directory to the new location. For example, the default installation places MySQL in C:\mysql and the data directory in C:\mysql\data. If you want to use a data directory of E:\mydata, you must copy C:\mysql\data there. You will also need to use a -datadir option to specify the location of the new data directory.
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 discussion.
There are two option files with the same function: C:\my.cnf, and the my.ini file in the Windows directory. (This directory typically is named 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. However, to avoid confusion, it's best if you use only one of these files. Both files are plain text.
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 the notepad program, create the option file and edit the [mysqld] section to specify values for the basedir and datadir parameters:
[mysqld] # set basedir to your installation path, for example, C:/mysql basedir=the_install_path # set datadir to the location of your data directory, # for example, 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.
Now you are ready to test starting the server.
Testing is best done from a command prompt in a console window (a "DOS window"). This way you can have the server display status messages in the window where they are easy to see. 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:
shell mysqld --console
For servers that include InnoDB support, you should see the following messages as the server starts up:
InnoDB: The first specified datafile 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
When the server finishes its startup sequence, you should see something like this, which indicates that the server is ready to service client connections::
mysqld: ready for connections Version: '4.0.14-log' socket: '' port: 3306
The server will continue to write to the console any further diagnostic output it produces. You can open a new console window in which to run client programs.
If you omit the -console option, the server writes diagnostic output to the error log in the data directory. The error log is the file with the .err extension.
For further information about running MySQL on Windows, see Section 2.6.1, “Windows Notes ”.
The recommended way to install MySQL on Linux is by using the RPM packages. The MySQL RPMs are currently built on a SuSE Linux 7.3 system but should work on most 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.2.1, “Linux Notes for Binary Distributions ”.
In most cases, you only need to install the MySQL-server and MySQL-client packages to get a functional MySQL installation. The other packages are not required for a standard installation. If you want to run a MySQL Max server that has additional capabilities, you should install the MySQL-Max RPM after installing the MySQL-server RPM. Section 4.7.5, “mysqld-max, An Extended mysqld Server ”.
If you get a dependency failure when trying to install the MySQL 4.0 packages (for example, "error: removing these packages would break dependencies: libmysqlclient.so.10 is needed by ..."), you should also install the package MySQL-shared-compat, which includes both the shared libraries for backward compatibility (libmysqlclient.so.12 for MySQL 4.0 and libmysqlclient.so.10 for MySQL 3.23).
Many Linux distributions still ship with MySQL 3.23 and they usually link applications dynamically to save disk space. If these shared libraries are in a separate package (for example, MySQL-shared), it is sufficient to simply leave this package installed and just upgrade the MySQL server and client packages (which are statically linked and do not depend on the shared libraries). For distributions that include the shared libraries in the same package as the MySQL server (for example, Red Hat Linux), you could either install our 3.23 MySQL-shared RPM, or use the MySQL-shared-compat package instead.
The following RPM packages are available:
MySQL-server-VERSION.i386.rpm
The MySQL server. You will need this unless you only want to connect to a MySQL server running on another machine. Please note that this package was called MySQL-VERSION.i386.rpm before MySQL 4.0.10.
MySQL-Max-VERSION.i386.rpm
The MySQL Max server. This server has additional capabilities that the one in the MySQL-server RPM does not. You must install the MySQL-server RPM first, because the MySQL-Max RPM depends on it.
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 the DBD-mysql module.
MySQL-devel-VERSION.i386.rpm
The libraries and include files that are needed if you want to compile other MySQL clients, such as the Perl modules.
MySQL-shared-VERSION.i386.rpm
This package contains the shared libraries (libmysqlclient.so*) that certain languages and applications need to dynamically load and use MySQL.
MySQL-shared-compat-VERSION.i386.rpm
This package includes the shared libraries for both MySQL 3.23 and MySQL 4.0. Install this package instead of MySQL-shared, if you have applications installed that are dynamically linked against MySQL 3.23 but you want to upgrade to MySQL 4.0 without breaking the library dependencies. This package is available since MySQL 4.0.13.
MySQL-embedded-VERSION.i386.rpm
The embedded MySQL server library (from MySQL 4.0).
MySQL-VERSION.src.rpm
This contains the source code for all of the previous packages. It can also be used to rebuild the RPMs on other architectures (for example, Alpha or SPARC).
To see all files in an RPM package (for example, a MySQL-server RPM), run:
shell rpm -qpl MySQL-server-VERSION.i386.rpm
To perform a standard minimal installation, run:
shell rpm -i MySQL-server-VERSION.i386.rpm MySQL-client-VERSION.i386.rpm
To install just the client package, run:
shell rpm -i MySQL-client-VERSION.i386.rpm
The server RPM places data under the /var/lib/mysql directory. The RPM also creates the appropriate entries in /etc/init.d/ to start the server automatically at boot time. (This means that if you have performed a previous installation and have made changes to its startup script, you may want to make a copy of the script so you don't lose it when you install a newer RPM.) See Section 2.4.3, “Starting and Stopping MySQL Automatically ” for more information on how MySQL can be started automatically on system startup.
If you want to install the MySQL RPM on older Linux distributions that do not support initialisation scripts in /etc/init.d (directly or via a symlink), you should create a symbolic link that points to the location where your initialisation scripts actually are installed. For example, if that location is /etc/rc.d/init.d, use these commands before installing the RPM to create /etc/init.d as a symbolic link that points there:
shell cd /etc ; ln -s rc.d/init.d .
However, all current major Linux distributions should already support the new directory layout that uses /etc/init.d, because it is required for LSB (Linux Standard Base) compliance.
If the RPM files that you install include MySQL-server, the mysqld daemon should be up and running after installation. You should now be able to start using MySQL. Section 2.4, “Post-installation Setup and Testing ”.
If something goes wrong, you can find more information in the binary installation chapter. Section 2.2.11, “Installing a MySQL Binary Distribution ”.
Beginning with MySQL 4.0.11, you can install MySQL on Mac OS X 10.2 ("Jaguar") using a Mac OS X PKG binary package instead of the binary tarball distribution. Please note that older versions of Mac OS X (for example, 10.1.x) are not supported by this package.
The package is located inside a disk image (.dmg) file, that you first need to mount by double-clicking its icon in the Finder. It should then mount the image and display its contents.
NOTE: Before proceeding with the installation, be sure to shut down all running MySQL server instances by either using the MySQL Manager Application (on Mac OS X Server) or via mysqladmin shutdown on the command line.
To actually install the MySQL PKG, double click on the package icon. This launches the Mac OS Package Installer, which will guide you through the installation of MySQL.
The Mac OS X PKG of MySQL will install itself into /usr/local/mysql-version and will also install a symbolic link /usr/local/mysql, pointing to the new location. If a directory named /usr/local/mysql already exists, it will be renamed to /usr/local/mysql.bak first. Additionally, it will install the grant tables in the mysql database by executing mysql_install_db after the installation.
The installation layout is similar to the one of the binary distribution; all MySQL binaries are located in the directory /usr/local/mysql/bin. The MySQL socket file is created as /tmp/mysql.sock by default. Section 2.2.7, “Installation Layouts ”.
MySQL installation requires a Mac OS X user account named mysql (a user account with this name should exist by default on Mac OS X 10.2 and up).
If you are running Mac OS X Server, you already have a version of MySQL installed:
Mac OS X Server 10.2-10.2.2 come with MySQL 3.23.51 installed
Mac OS X Server 10.2.3-10.2.6 ship with MySQL 3.23.53
This manual section covers the installation of the official MySQL Mac OS X PKG only. Make sure to read Apple's help about installing MySQL (Run the "Help View" application, select "Mac OS X Server" help, and do a search for "MySQL" and read the item entitled "Installing MySQL").
Especially note that the pre-installed version of MySQL on Mac OS X Server is started with the command safe_mysqld instead of mysqld_safe.
If you previously used Marc Liyanage's MySQL packages for Mac OS X from http://www.entropy.ch, you can simply follow the update instructions for packages using the binary installation layout as given on his pages.
If you are upgrading from Marc's 3.23.xx versions or from the Mac OS X Server version of MySQL to the official MySQL PKG, you also need to convert the existing MySQL privilege tables to the current format, because some new security privileges have been added. Section 2.5.6, “Upgrading the Grant Tables ”.
If you would like to automatically start up MySQL during system bootup, you also need to install the MySQL Startup Item. Starting with MySQL 4.0.15, it is part of the Mac OS X installation disk images as a separate installation package. Simply double-click the MySQLStartupItem.pkg icon and follow the instructions to install it.
Note that this only has to be done once! There is no need to install the Startup Item every time you upgrade the MySQL package.
The Startup Item will be installed into /Library/StartupItems/MySQL. It adds a variable MYSQLCOM=-YES- to the system configuration file /etc/hostconfig. If you would like to disable the automatic startup of MySQL, simply change this variable to MYSQLCOM=-NO-.
On Mac OS X Server, the Startup Item installation script will automatically disable the startup of the default MySQL installation by changing the variable MYSQL in /etc/hostconfig to MYSQL=-NO-. This is to avoid conflicts on bootup. However, it does not shut down an already running MySQL server.
After the installation, you can start up MySQL by running the following commands in a terminal window. Please note that you need to have administrator privileges to perform this task.
If you have installed the Startup Item:
shell sudo /Library/StartupItems/MySQL/MySQL start (Enter your password, if necessary) (Press Control-D or enter "exit" to exit the shell)
If you don't use the Startup Item, enter the following command sequence:
shell cd /usr/local/mysql shell sudo ./bin/mysqld_safe (Enter your password, if necessary) (Press Control-Z) shell bg (Press Control-D or enter "exit" to exit the shell)
You should now be able to connect to the MySQL server, for example, by running /usr/local/mysql/bin/mysql.
If you installed MySQL for the first time, please remember to set a password for the MySQL root user!
This is done with the following two commands:
/usr/local/mysql/bin/mysqladmin -u root password password /usr/local/mysql/bin/mysqladmin -u root -h `hostname` password password
Please make sure that the hostname command in the second line is enclosed by backticks (`), so the shell can replace it with the output of this command (the host name of this system)!
You might want to also add aliases to your shell's resource file to access mysql and mysqladmin from the command line:
alias mysql '/usr/local/mysql/bin/mysql' alias mysqladmin '/usr/local/mysql/bin/mysqladmin'
Alternatively, you could simply add /usr/local/mysql/bin to your PATH environment variable, for example, by adding the following to $HOME/.tcshrc:
setenv PATH ${PATH}:/usr/local/mysql/bin
Please note that installing a new MySQL PKG does not remove the directory of an older installation. Unfortunately, the Mac OS X Installer does not yet offer the functionality required to properly upgrade previously installed packages.
After you have copied over the MySQL database files from the previous version and have successfully started the new version, you should consider removing the old installation files to save disk space. Additionally, you should also remove older versions of the Package Receipt directories located in /Library/Receipts/mysql-version.pkg.
As of version 4.0.11, the MySQL server is available for Novell NetWare in binary package form. In order to host MySQL, the NetWare server must meet these requirements:
NetWare version 6.5, or NetWare 6.0 with Support Pack 3 installed (You can obtain this at http://support.novell.com/filefinder/13659/index.html). The system must meet Novell's minimum requirements to run the respective version of NetWare.
MySQL data, as well as the binaries themselves, must be installed on an NSS volume; traditional volumes are not supported.
The binary package for NetWare can be obtained at http://www.mysql.com/downloads/.
If you are running MySQL on NetWare 6.0, we strongly suggest that you use the -skip-external-locking option on the command line. It will also be neccesary to use CHECK TABLE and REPAIR TABLE instead of myisamchk, because myisamchk makes use of external locking. External locking is known to have problems on NetWare 6.0; the problem has been eliminated in NetWare 6.5.
If you are upgrading from a prior installation, stop the MySQL server. This is done from the server console, using:
SERVER: mysqladmin -u root shutdown
Log on to the target server from a client machine with access to the location where you will install MySQL.
Extract the binary package zip file onto the server. Be sure to allow the paths in the zip file to be used. It is safe to simply extract the file to SYS:\.
If you are upgrading from a prior installation, you may need to copy the data directory (for example, SYS:MYSQL\DATA) now, as well as my.cnf if you have customised it. You can then delete the old copy of MySQL.
You may wish to rename the directory to something more consistent and easy to use. We recommend using SYS:MYSQL; examples in the manual will use this to refer to the installation directory in general.
At the server console, add a search path for the directory containing the MySQL NLMs. For example:
SERVER: SEARCH ADD SYS:MYSQL\BIN
Install the initial database, if needed, by executing mysql_install_db at the server console.
Start the MySQL server using mysqld_safe at the server console.
To finish the installation, you should also add the following commands to autoexec.ncf. For example, if your MySQL installation is in SYS:MYSQL and you want MySQL to start automatically, you could add these lines:
#Starts the MySQL 4.0.x database server SEARCH ADD SYS:MYSQL\BIN MYSQLD_SAFE
If you are using NetWare 6.0, you should add the -skip-external-locking flag:
#Starts the MySQL 4.0.x database server SEARCH ADD SYS:MYSQL\BIN MYSQLD_SAFE --skip-external-locking
If there was an existing installation of MySQL on the server, be sure to check for existing MySQL startup commands in autoexec.ncf, and edit or delete them as necessary.