(mysql.info.gz) Windows start service
Info Catalog
(mysql.info.gz) Windows start command line
(mysql.info.gz) Windows installation
(mysql.info.gz) Windows testing
2.3.12 Starting MySQL as a Windows Service
------------------------------------------
On the NT family (Windows NT, 2000, XP, 2003), the recommended way to
run MySQL is to install it as a Windows service. When MySQL is
installed as a service, Windows starts and stops the MySQL server
automatically when Windows starts and stops. A server installed as a
service can also be controlled from the command line using `NET'
commands, or with the graphical `Services' utility.
The `Services' utility (the Windows `Service Control Manager') can be
found in the Windows `Control Panel' (under `Administrative Tools' on
Windows 2000, XP, and Server 2003). It is advisable to close the
`Services' utility while performing server installation or removal
operations from this command line. This prevents some odd errors.
To get MySQL to work with TCP/IP on Windows NT 4, you must install
service pack 3 (or newer).
Before installing MySQL as a Windows service, you should first stop the
current server if it is running by using the following command:
C:\> C:\mysql\bin\mysqladmin -u root shutdown
This invokes the MySQL administrative utility `mysqladmin' to connect
to the server and tell it to shut down. The command connects as `root',
which is the default administrative account in the MySQL grant system.
Note that users in the MySQL grant system are wholly independent from
any login users under Windows.
Install the server as a service:
C:\> mysqld --install
If you have problems installing `mysqld' as a service using just the
server name, try installing it using its full pathname:
C:\> C:\mysql\bin\mysqld --install
As of MySQL 4.0.2, you can specify a specific service name after the
`--install' option. As of MySQL 4.0.3, you can in addition specify a
`--defaults-file' option after the service name to indicate where the
server should obtain options when it starts. The rules that determine
the service name and option files the server uses are as follows:
* If you specify no service name or a name of `MySQL', the server
uses the default service name of `MySQL' and the reads options from
the `[mysqld]' group in the standard option files.
* If you specify a service name other than `MySQL' after the
`--install' option, the server reads options from the group that
has the same name as the service. The server reads options from
the standard option files.
As of MySQL 4.0.17, the server also reads options from the
`[mysqld]' group from the standard option files. This allows you
to use the `[mysqld]' group for options that should be used by all
MySQL services, and an option group named after each service for
use by the server installed with that service name.
* If you specify a `--defaults-file' option after the service name,
the server ignores the standard option files and reads options
only from the `[mysqld]' group of the named file.
* Prior to MySQL 4.0.17, a server installed as a Windows service
has problems starting if its pathname or the service name contains
spaces. For this reason, with older versions, avoid installing MySQL in
a directory such as `C:\Program Files' or using a service name
containing spaces.
As a more complex example, consider the following command:
C:\> C:\mysql\bin\mysqld --install MySQL --defaults-file=C:\my-opts.cnf
Here, the default service name (`MySQL') is given after the `--install'
option. If no `--defaults-file' option had been given, this command
would have the effect of causing the server to read the `[mysqld]'
group from the standard option files. However, because the
`--defaults-file' option is present, the server reads options from the
`[mysqld]' option group, but only from the named file.
You can also specify options as "`Start parameters'" in the Windows
`Services' utility before you start the MySQL service.
Once a MySQL server is installed as a service, Windows will start the
service automatically whenever Windows starts. The service also can be
started immediately from the `Services' utility, or by using the
command `NET START MySQL'. The `NET' command is not case sensitive.
When run as a service, `mysqld' has no access to a console window, so
no messages can be seen there. If `mysqld' doesn't start, check the
error log to see whether the server wrote any messages there to
indicate the cause of the problem. The error log is located in the
`C:\mysql\data' directory. It is the file with a suffix of `.err'.
When `mysqld' is running as a service, it can be stopped by using the
`Services' utility, the command `NET STOP MySQL', or the command
`mysqladmin shutdown'. If the service is running when Windows shuts
down, Windows will stop the server automatically.
From MySQL 3.23.44 on, you have the choice of installing the server as
a `Manual' service if you don't wish the service to be started
automatically during the boot process. To do this, use the
`--install-manual' option rather than the `--install' option:
C:\> C:\mysql\bin\mysqld --install-manual
To remove a server that is installed as a service, first stop it if it
is running. Then use the `--remove' option to remove it:
C:\> C:\mysql\bin\mysqld --remove
For MySQL versions older than 3.23.49, one problem with automatic MySQL
service shutdown is that Windows waited only for a few seconds for the
shutdown to complete, then killed the database server process if the
time limit was exceeded. This had the potential to cause problems.
(For example, the `InnoDB' storage engine had to perform crash recovery
at the next startup.) Starting from MySQL 3.23.49, Windows waits longer
for the MySQL server shutdown to complete. If you notice this still is
not enough for your installation, it is safest not to run the MySQL
server as a service. Instead, start it from the command-line prompt,
and stop it with `mysqladmin shutdown'.
This change to tell Windows to wait longer when stopping the MySQL
server works for Windows 2000 and XP. It does not work for Windows NT,
where Windows waits only 20 seconds for a service to shut down, and
after that kills the service process. You can increase this default by
opening the Registry Editor `\winnt\system32\regedt32.exe' and editing
the value of `WaitToKillServiceTimeout' at
`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control' in the Registry
tree. Specify the new larger value in milliseconds. For example, the
value 120000 tells Windows NT to wait up to 120 seconds.
If you don't want to start `mysqld' as a service, you can start it from
the command line. For instructions, see Windows start command
line.
Please see Windows troubleshooting if you encounter difficulties
during installation.
Info Catalog
(mysql.info.gz) Windows start command line
(mysql.info.gz) Windows installation
(mysql.info.gz) Windows testing
automatically generated byinfo2html