Installing MySQL on a server using Windows is fairly easy. If MySQL is already installed and running on your server and you want to install a newer version, you will need to shut down the existing one first. For server versions of MS Windows (e.g., Windows NT), MySQL is installed as a service. If it’s installed as a service on your server, you can enter the following from a DOS command window to shut down the service and remove it:
mysqld -remove
If MySQL is running, but not as a service, you can enter the following from a DOS command window to shut it down:
msyqladmin -u root shutdown
MySQL AB’s site (http://dev.mysql.com/downloads/) contains three installation packages: a Windows Essential package, a standard Windows package, and a standard Windows package without the installer. The Windows Essential package is the recommended format. It contains only the essential files for running MySQL. This includes the usual command-line utilities and the header files for the C API. The standard Windows package contains the essential files, as well as documentation, the MySQL Administrator, the embedded server, the benchmark suite, and a few other useful scripts. The standard Windows package without the installer contains the same binary files and other related files for MySQL, but not an installer. You’ll need to extract and copy the files into the c:\mysql directory. Then, you must create a my.ini file in the c:\windows directory. Several examples showing different server usage come with the distribution package.
The Windows Essential package is a file called
MySQL-version.msi. From
the Windows desktop, just double-click this file’s icon and the Windows
Installer program will start.
The standard Windows installation package is a compressed file from which you have to extract the installation files. To do this, you need a utility such as WinZip (http://www.winzip.com) to uncompress the files. One of the files is named setup.exe. Double-click it to start the installer for this package. From this point, the installation process is pretty much the same for the packages that use the installer.
Once you’ve started the installer, a dialog box appears that offers
you three general choices. The Typical choice is the
recommended one, but it will omit the installation of C API include files
and other client libraries. For the standard Windows package, this choice
will also omit installation of the embedded server, the benchmark suite,
and several other scripts. The Complete installation
choice instructs the installer to install everything that’s included in
the distribution package that you downloaded. The
Custom choice allows you to choose from a list of
programs and libraries to install. On the same screen is a button labeled
Change that lets you change the directory in which
MySQL will be installed. Older versions of MySQL use c:\mysql as the default. Recent versions
install MySQL by default in directories like c:\Program
Files\MySQL\MySQL Server
version\, where the word
version is replaced with the version number.
After you choose what to install and where, the files are installed. When the installer is finished, the MySQL Server Instance Configuration Wizard is started. It asks you a series of questions to create a server configuration file (my.ini), which, by default, is stored in c:\windows. The questions are based on the intended usage of the MySQL server, and your answers determine the contents of the configuration file. You will also be allowed to change the default location of the datafiles, the TCP/IP port used, and a couple of other settings.
To invoke the command-line utilities without having to enter the file path to the directory containing them, enter the following from the command line:
PATH=%PATH%;c:\Program Files\MySQL\MySQL Server version\binYou should replace the word version with
the version number—that is to say, you should enter the path to the MySQL installation. If you changed location when you
installed MySQL, you need to use the path that you named. Older versions
of Windows may not accept long directory names in the startup file.
Therefore, you may need to abbreviate the line shown previously so that it
looks something like this:
PATH=%PATH%;c:\Program~1\MySQL\MySQLS~1.1\bin
The characters ~1 are substitutes for the extra
characters of a directory name that follow the first seven characters. An
S is a substitute for any space that occurs in the
first seven characters of a directory name. If the directory name ends in
a dot and more characters, the last dot and characters are given. For
example, a directory named “MySQL Server 4.1” would be entered as
“MySQLS~1.1,” as shown in the previous command. To make this new path
available at boot time, you may want to add it to the
c:\autoexec.bat file.
Once you’ve finished installing MySQL and you’ve set up the configuration file, the installer will start the MySQL server automatically. If you’ve installed MySQL manually without an installer, enter something like the following from a DOS command window:
mysqld --install net start mysql
All that remains are some postinstallation adjustments that are explained in the next section.