Search the MySQL manual:

2.1.1.2 Preparing the Windows MySQL Environment

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:

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.

User Comments

Posted by Dave Smith on Wednesday May 29 2002, @1:35pm[Delete] [Edit]

If you are unable to start your service check the
basedir doesn't have any spaces. I had to
replace "c:/program files/mysql"
with "c:/progra~1/mysql".

Posted by Franz Nisswandt on Wednesday April 30 2003, @1:33pm[Delete] [Edit]

With 4.012 on Windows, I was unable to get the datadir to work. I had the base installation in c:\mysql\data, and created a new folder e:\mysql\data and moved the data contents to e:\mysql\data.

In my.ini, I tried (to no avail):

datadir=e:/mysql/data
datadir=e:/mysql/data/

Finally, I left my 15GB database in e:/mysql/data/foo and created a symbolic link in c:\mysql\data named like my database folder (foo.sym) with the file contents pointing to e:\mysql\data\foo\, moved the other mysql tables (security, etc) back to c:\mysql\data, and voila, I can have a database on a different drive than the installation.

Posted by Rolando E. Cruz-Marshall on Wednesday July 2 2003, @11:38am[Delete] [Edit]

I had the same problems and could not get the mySQL server to run as a service. I did the following and not sure which of the two corrected the problem... I would like to think the send of the two.

1. Uninstalled and reinstalled MySQL server. In my case I installed on my E drive.

2. Modified my.ini file (C:\winnt\ folder) and changes all the / for \. Also added the datadir and basedir values.

After doing this the service came right up without any problems.

Hope this helps.

Rolando

Add your own comment.