Lancer MySQL en ligne de commande
<<<
Lancer MySQL comme un service Windows Faire fonctionner MySQL sous Windows
>>>

2.2.1 Installer MySQL sous Windows
2.2 Installation standard rapide de MySQL
2 Installer MySQL
 Manuel de Référence MySQL 4.1 : Version Française

Prérequis système sur Windows
Installation d'une distribution binaire sur Windows
Préparation de l'environnement MySQL de Windows
Choisir un serveur Windows
Démarrer le serveur pour la première fois
Lancer MySQL en ligne de commande
->Lancer MySQL comme un service Windows
Faire fonctionner MySQL sous Windows
MySQL pour Windows face à MySQL pour Unix

2.2.1.7 Lancer MySQL comme un service Windows

Dans la famille NT (Windows NT, 2000 ou XP), the recommended way to run MySQL is to install it as a Windows service. Then 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). 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:

shell> 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. Please note that users in the MySQL grant system are wholly independent from any login users under Windows.Now install the server as a service:

shell> mysqld --install
If you have problems installing mysqld as a service using just the server name, try installing it using its full pathname:

shell> 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 up. The rules that determine the service name and option files the server uses are as follows:

  • If you specify no service name, the server uses the default service name of MySQL and the server reads options from the [mysqld] group in the standard option files.
  • If you specify a service name after the --install option, the server ignores the [mysqld] option group and instead reads options from the group that has the same name as the service. The server reads options from the standard option files.
  • 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.
Note: 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, avoid installing MySQL in a directory such as C:\Program Files or using a service name containing spaces.

In the usual case that you install the server with --install but no service name, the server is installed with a service name of MySQL .

As a more complex example, consider the following command:

shell> C:\mysql\bin\mysqld --install mysql --defaults-file=C:\my-opts.cnf
Here, a service name 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 [mysql] group from the standard option files. (This would be a bad idea, because that option group is for use by the mysql client program.) However, because the --defaults-file option is present, the server reads options only from the named file, and only from the [mysqld] option group.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.

Please note that 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 if 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 version 3.23.44, 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:

shell> 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:

shell> mysqld --remove
One problem with automatic MySQL service shutdown is that, for MySQL versions older than 3.23.49, 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 version 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 .

The 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 the same way as for versions of Windows that are not based on NT. For instructions, see Lancer MySQL en ligne de commande Windows .

<< Lancer MySQL comme un service Windows >>
Lancer MySQL en ligne de commande Installer MySQL sous Windows Faire fonctionner MySQL sous Windows