MySQL, PHP, Apache for Windows - 1. MySQL 5 - Basic information and installation
- 1. Installed and properly running Windows OS, preferably NT/2000/XP/2003. The outdated Windows 9x can be used as well, but it is not supported and therefore not recommended to be used.
- 2. Free disk space for installation of files, databases and web files.
- 3. TCP/IP support (installed network card or MS Loopback).
- 4. Internet access or downloaded installation files for MySQL, PHP and Apache.
- 5. A compression program or a file manager to open compressed files (*.zip files).
- 6. System update. It is recommended that you have the latest Service Pack for Windows NT, SP3 or later for Windows NT 4.0.
Choosing which MySQL distribution to download and install
- As PHP and Apache, also MySQL offers you to choose from several types of installations. At http://dev.mysql.com/downloads/ you will find the files to download.
- What files are we looking for? You can choose from clients, servers and some other programs. But now we are only interested in the database server, as for installing a server with Apache and PHP. It is recommended that you use the new "MySQL administrator" tool for administration and setup. It can be found in the Graphical User Interface applications section and can be considered the successor to the WinMySQLAdmin which used to be a part of older versions.
- Choosing version - The older 3.xx version is not used anymore. The latest stable version is 5.0.xx. The 5.x version with the suffix "alpha" indicates that the version is still being developed and it has to go through the beta (and sometimes gamma and rc) phase before its stability can be approved. Those versions are not often used for website development. Though they bring new features and bug solutions, their code is not fully tested yet, and so they might cause problems with stability and may contain bugs that can affect the functionality of applications they have created. Detailed information you will find in the following manual: http://dev.mysql.com/doc/mysql/en/Choosing_version.html.
- Choosing operating system and platform - For the purposes of this article we are looking for Windows distributions. "x86" is quoted the current platform in 99 % cases. In the future, there should also appear versions optimized for 64-Bit computers.
- Binary distribution contains files for instant
use. If you choose the distribution with installer, just
unzip the files to a directory on your computer, choose a
destination folder and you can start using the server. If
you decide for the distribution without installer, copy
the files to a destination folder (then you have to follow certain steps to
set up and run the server).
Source distribution contains data files with code and support files for creation of an executable package, using the Visual Studio 2003.
Examples of distributions for Windows
mysql-4.0.18-win.zip - Binary with installer
mysql-4.0.18-win-noinstall.zip - Binary without installer
mysql-4.0.18-win-src.zip - Source
mysql-4.1.1a-alpha-win.zip - Binary with installer
mysql-4.1.1a-win-src.zip - Source
mysql-4.1.1a-alpha-win64.zip - Binary with installer for 64-Bit platform
mysql-5.0.0a-alpha-win.zip - Binary with installer
mysql-5.0.0a-alpha-win-noinstall.zip - Binary without installer
mysql-5.0.18-win32.zip - Binary with installer
mysql-noinstall-5.0.18-win32.zip - Binary without installer
a) With installer (recommended)
- I decided for the 5.0.18 version (mysql-5.0.18-win32.zip) because of its stability and easy installation. Unzip the file to a directory on your computer and run the installation clicking setup.exe.
- On the welcome screen, click Next. In the following window, choose [Custom] installation.
- Defining the installation folder. You can choose the default destination folder c:\mysql or just change it (use the Browse button). I decided for c:\inetpub\mysql. Avoid choosing an inappropriate directory. E.g. a space could cause problems (if you enter c:\mysq 5 or c:\program files\mysql or similar, you will probably face problems with running and configuring the application).
- In the Sign-Up window, I chose Skip for now and continued with the Next button.
- On the "Wizard Completed" screen, I left "Configure the MySQL Server now" unchecked.
Detail configuration using MySQL Instance Configuration Wizard
After the previously described steps have been executed, the MySQL Instance Configuration Wizard starts. It allows you to configure details without any special knowledge of the server. I chose "Detailed Configuration".
Server type - For developer purposes I chose "Developer Machine" with minimum memory requirements.
The Database Usage - I left the default "Multifunctional Database" checked
InnoDB TableSpace Settings - I left the default settings: "C:" and "Installation Path"
Concurrent Connections - I left "Decision Support (DSS)/OLAP" checked which is 20 concurrent connections.
Networking Options - You can change the port number here and require "strict mode" (a strict server mode).
Default Character Set - You can change the type of used coding here. The default option "Standard Character Set" is usually suficient.
When "cp1250" entered, could not run
mysql -u root in the command line
mysql: Character set 'cp1250' is not a compiled
character set and is not specified in the 'C:\mysql\\share\charsets\Index.xml'
Windows Options - Custom settings. Settings for configuring the server as a service, defining its name, setting up automatic service start and optional setup of mysql in system variables (Include Bin Directory in Windows PATH).
Security Options - I recommend that you change the password for the root users. Access from other computers is not usually allowed, if it is not really necessary, and creating anonymous users is quite rare.
Ready To Execute - Click the "Execute" button to finish the setup.
b) Without installer
- Download the distribution for 5.0.18 - mysql-noinstall-5.0.18-win32.zip. Unzip this file to a directory on your computer and rename the directory "mysql-5.0.18" to "mysql" (the path will look like this: c:\web\mysql).
bin Client programs and mysqld server
data Log files, databases
examples Example programs and scripts
include Include (header) files
scripts Utility scripts
share Error message and character set files
- After you run the server, your %windir%\ will be searched for my.ini or c:\my.cnf files which define the most of the basic settings. The file is automatically created by MySQL Instance Configuration Wizard, but it can also be created manually or using the already existing files from the mysql directory (according to the size of the server, choose and adjust one of the following files: my-huge.cnf, my-large.cnf, my-medium.cnf, my-small.cnf).
Example of a my.ini file
Example of a my.ini file (created by MySQL Instance Configuration Wizard)
|# MySQL Server Instance Configuration File
- Paths to folders where the configuration file will be searched: C:\my.ini C:\my.cnf C:\WINDOWS\my.ini C:\WINDOWS\my.cnf C:\web\mysql\my.ini C:\web\mysql\my.cnf)
- The next step is to choose and run a standalone server. According to the type of operating system and requirements, you can choose from the following:
|mysqld Compiled with full
debugging and automatic memory allocation checking,
symbolic links, and InnoDB and BDB tables.
mysqld-opt Optimized binary with support for InnoDB tables from version 4.0.
mysqld-nt Optimized binary for Windows NT, 2000, and XP with support for named pipes.
mysqld-max Optimized binary with support for symbolic links, and InnoDB and BDB tables.
mysqld-max-nt The same mysqld-max, but compiled with support for named pipes.
- Even the smallest error in the configuration file (even wrong or omitted character) can result in a problem with starting the server. If you run the server as a console, an error message displays on the screen. If you run the server as a service or if you have problems with the command line, you can search for the errors in the *.err file in the "data" directory. In an emergency case, you can run the server in the console mode with adding --debug (there will be a *.trace file created in the root directory of the C disk).
Running the server
- If the installer and MySQL Instance Configuration Wizard have been used, it is not necessary for you to read on. The following words are dedicated to explanation of how to start and keep the server running.
- The Wizard creates this service: C:\web\mysql\bin\mysqld-nt --defaults-file="C:\web\mysql\my.ini" "MySQL"
- Service - In Windows NT (2000, XP, 2003), the server can be installed as a service with manual or automatic start.
- Standalone - Starting and shutting down is executed in the command line. The application runs as a standalone program.
- Installation, removal and start are executed from the command line.
|mysqld-nt --install (installation of the
service with automatic startup on Windows start)
mysqld-nt --install-manual (installation of the service with manual start)
NET START MySQL (manual start of the service)
b) In the console mode (as a standalone program)
mysqld-nt --standalone --console
(c:\web\mysql\bin\mysqld-nt --standalone --console)
|C:\web\mysql\bin>mysqld-nt.exe --standalone --console
060316 13:47:24 InnoDB: Started; log sequence number 0 283089
060316 13:47:24 [Note] mysqld-nt.exe: ready for connections.
Version: '5.0.18-nt' socket: '' port: 3306 MySQL Community Edition (GPL)
060316 20:53:47 [Note] mysqld-nt.exe: Normal shutdown
Example of starting and shutting down the service in the console mode