Chạy mysql 5.7 service windows
2.3.4.8 Starting MySQL as a Windows ServiceOn Windows, the recommended way to run MySQL is to install it as a Windows service, so that MySQL starts and stops automatically when Windows starts and stops. A MySQL server installed as a service can also be controlled from the command line using NET commands, or with the graphical Services utility. Generally, to install MySQL as a Windows service you should be logged in using an account that has administrator rights. The Services utility (the Windows Service Control Manager) can be found in the Windows Control Panel. To avoid conflicts, it is advisable to close the Services utility while performing server installation or removal operations from the command line. Installing the serviceBefore installing MySQL as a Windows service, you should first stop the current server if it is running by using the following command:
Note If the MySQL This command invokes the MySQL administrative utility mysqladmin to connect to the server and tell it to shut down. The command connects as the MySQL Note Users in the MySQL grant system are wholly independent from any operating system users under Windows. Install the server as a service using this command:
The service-installation command does not start the server. Instructions for that are given later in this section. To make it easier to invoke MySQL programs, you can add the path name of the MySQL
Warning You must exercise great care when editing your system The following additional arguments can be used when installing the service:
For a MySQL server that is installed as a Windows service, the following rules determine the service name and option files that the server uses:
As a more complex example, consider the following command:
Here, the default service name ( Note On Windows, if the server is started with the
You can also specify options as Start parameters in the Windows Services utility before you start the MySQL service. Finally, before trying to start the MySQL service, make sure the user variables Starting the service After a MySQL server instance has been installed as a service, Windows starts the service automatically whenever Windows starts. The service also can be started immediately from the Services utility, or by using an sc start When run as a service, mysqld has no access to a console window, so no messages can be seen there. If
mysqld does not 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 MySQL data directory (for example, When a MySQL server has been installed as a service, and the service is running, Windows
stops the service automatically when Windows shuts down. The server also can be stopped manually using the You also
have the choice of installing the server as a manual service if you do not wish for the service to be started automatically during the boot process. To do this, use the
Removing the service To remove a server that is installed as a service, first stop it if it is running by executing SC STOP
Alternatively, use the mysqld
If mysqld is not running as a service, you can start it from the command line. For instructions, see Section 2.3.4.6, “Starting MySQL from the Windows Command Line”. If you encounter difficulties during installation, see Section 2.3.5, “Troubleshooting a Microsoft Windows MySQL Server Installation”. For more information about stopping or removing a Windows service, see Section 5.7.2.2, “Starting Multiple MySQL Instances as Windows Services”. |