MySQL, PHP, Apache for Windows - 1. MySQL - General information and installation
- Requirements: 1. Running Windows (NT/2000/XP/2003 recommended. Windows 9x can also be used, but it is not supported and not recommended). 2. Free disk space for installation files, databases and web files. 3. TCP/IP support (installed network card or MS Loopback). 4. Access to Internet or downloaded installation files for MySQL, PHP and Apache. 5. A compression program or a file manager able to handle 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 and Winsock 2.0 for Windows 95.
Choosing which MySQL distribution to download and install
- As in case of PHP and Apache, MySQL offers you to choose from several types of installations. At www.mysql.com you will find the files to download.
- What files do we look for? You can choose from clients, servers and some other programs. But now we are only interested in the database server. It is recommended that you use the new "MySQL administrator" tool for administration and setup. It can be found in the graphic clients section. When I was writing this article, there only existed the alfa version, and so I do not review the functions here, however, in the future, this tool could replace the currently used WinMySQLAdmin).
- Choosing version - The older 3.xx versions are not used anymore. The latest stable version is 4.0.xx. The suffix "alpha" indicates the stability level of the release, which means that the version is still developing (4.1 and 5.x versions). They have to go through the "beta" and "gamma" phases to be approved for stable. These versions are not usually used for creating webs. They bring some new features and bug solutions, but they still contain not 100 % tested code, can have problems with stability and can contain bugs that can affect the functionality of applications they have created. Detailed information you will find here: http://dev.mysql.com/doc/mysql/en/Choosing_version.html.
- Choosing operating system and platform - We look for distributions for Windows. The current platform is "x86" in 99 %, in the future there will also be a version optimized for 64-Bit computers and Windows XP 64.
- Binary distribution contains files for immediate
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 have chosen the distribution without installer, copy
the files to the destination folder (then you just have
to setup and run the server).
Source distribution contains data files with a code and support files for creation of an executable package, using the VC +++ 6.0.
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 a 64Bit platform
mysql-5.0.0a-alpha-win.zip - Binary with installer
mysql-5.0.0a-alpha-win-noinstall.zip - Binary without installer
a.) With installer
- I have chosen the 4.00.18 version (mysql-4.0.18-win.zip), because it is stable and easy to install. Unzip the file to a directory on your computer and run the installation clicking on setup.exe.
- Follow the instructions and enter the path.
- Choosing the installation directory. You can choose the default destination folder c:\mysql or change it (use the Browse button). I have chosen c:\web\mysql. Avoid choosing an inappropriate directory. E. g. a space could cause problems (if you enter c:\mysq 4 or c:\program files\mysql or similar, you will probably face problems with running and configuring the application).
- Choose the typical installation and let the installation finish.
b.) Without installer
- Download mysql-4.0.18-win-noinstall.zip. Unzip it to a directory on your computer and rename the directory "mysql-4.0.18" to "mysql" (the path will look like this: c:\web\mysql).
- After you run the server, your %windir%\ will be searched for my.ini or c:\my.cnf files that define the settings. The file is automatically created by the winmysqladmin application, 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).
- The next step is to choose a standalone server and run it. 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. From version 4.0 on, InnoDB is enabled. Before 4.0, this server includes no transactional table support.
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 Like mysqld-max, but compiled with support for named pipes.
Example of the my.ini file
basedir = C:/ezpublish/mysql
datadir = C:/ezpublish/mysql/data
- Even the smallest error in the configuration file (a wrong or an omitted character) can result in a problem with starting the server, which means that it does not run at all. If you run the server as a console, an error message displayes on the screen. If you run the server as a service or if you have problems with the command line, you can find the errors in the *.err file in the "data" directory. In case of emergency, 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
- There are two ways to run the server:
- Standalone - Using the command line. The applications run as standalone programs.
- Service - In Windows NT, it can be installed as a service. Then you can start it manually or set it to start upon Windows start.
a.) Winmysqladmin and Service
Run winmysqladmin from the c:\web\mysql\bin directory.
- Enter the user name and the password for your applications. For testing you do not need to enter password. If you want to use the applications for Internet servers, your user name and password should be hard to reveal. I used user1 and pass1 (only for the purposes of this article).
- The program creates the "my.ini" file and copies it to the Windows root directory. The my.ini file will be created after entering the destination folder for installation and data and after entering the user name, password and the type of server. Here are some lines that are deactivated by the "#" character. If the my.cnf file is found (this is the second type of configuration file after my.ini that will be searched), it gets renamed to my_cnf.bak and is determined as not used.
- Follow these steps: 1. Install MySQL as a service (if the server does not run as standalone or if the service does not run already). 2. Set the application to run at computer startup (you will be notified by the icon in the right bottom corner).
- Icon - displayes the server status. It enables to run, stop, unistall or install the service. It enables to exit the WinMySQLAdmin application.
- Name and password - You do not need the name and the password in the default setup of mysql. If you use restrictions (access restrictions or "password required" restriction) and you enter a wrong name, WinMySQL will not work and you will be only able to display basic information, Start Check and change my.ini.
b.) Using the command line
|mysqld-nt --install (installation of the
service with automatic startup after Windows starts)
mysqld-nt --install-manual (installation of the service with manual start)
NET START MySQL (installation of the service)
mysqld-nt --standalone --console (Running the server in the console mode and as a standalone program)
- Use WinMySQLAdmin to stop and remove the service. Exit WinMySQLAdmin.
- You can do the same using the command line:
|NET STOP MySQL (stopping the
mysqld --remove (removing the service)
mysqladmin -u root shutdown (Server / Service shutdown)
- Go to Control Panels - Add or Remove Programs - uninstall MySQL. It is recommended that you backup all the data files and dabases before uninstalling. The configuration files in the root directory will not be removed by the uninstallation (my.ini).
Installing more servers on one comptuer
- You can run several servers on one computer. For each server you have to adjust the configuration, to set different data destination, name of service and port numbers.
- Separate particular services in my.ini file by their names in braces [name_of_service]. There must be a different name, directory and port for each service.
set-variable = key_buffer=16K
set-variable = max_allowed_packet=1M
set-variable = thread_stack=64K
set-variable = table_cache=4
set-variable = sort_buffer=64K
set-variable = net_buffer_length=2K
server-id = 1
- You can determine a file for each service, e. g. my_1.cnf , and so setup the service differently from the other services.
Batch file for installing and starting servers
- There exist 4 directories on the disk. In the first one - mysql - we have pre-created configuration files and batches. The first one is an installation batch that copies the files to the corresponding directories, installs the services and if you have the mysqls41 service it assigns configuration files (--defaults-file=c:\my_1.cnf). The services start for the first time after the installation and then they always run automatically.
copy c:\mysql\my.ini c:\windows
copy c:\mysql\my_1.cnf c:\
c:\mysql4\bin\mysqld-nt --install mysqls4
c:\mysql41\bin\mysqld-nt --install mysqls41 --defaults-file=c:\my_1.cnf
c:\mysql5\bin\mysqld-nt --install mysqls5
net start mysql
net start mysqls4
net start mysqls41
net start mysqls5
Batch file for stopping and uninstalling servers
- This batch stops services, removes them and deletes configuration files.
net stop mysql
net stop mysqls4
net stop mysqls41
net stop mysqls5
c:\mysql4\bin\mysqld-nt --remove mysqls4
c:\mysql41\bin\mysqld-nt --remove mysqls41
c:\mysql5\bin\mysqld-nt --remove mysqls5