content_image/718404.jpg content_image/718405.jpg
## 2.3.4.8 Starting MySQL as a Windows Service 

On 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 service 

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:\Program Files\MySQL\MySQL Server 8.0\bin\mysqladmin" -u root shutdown 

<img src='content_image/718404.jpg'>

## Note 

If the MySQL root  user account has a password, you need to invoke mysqladmin with the -p  option and supply the password when prompted. 

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 root  user, which is the default administrative account in the MySQL grant system. 

<img src='content_image/718405.jpg'>

Install the server as a service using this command: 

C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld" --install 

## Note 

Users in the MySQL grant system are wholly independent from any operating system users under Windows. 

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 bin  directory to your Windows system PATH  environment variable: 

•On the Windows desktop, right-click the My Computer  icon, and select Properties . 

•Next select the Advanced  tab from the System Properties  menu that appears, and click the Environment Variables  button. 

•Under System Variables , select Path , and then click the Edit  button. The Edit System Variable dialogue should appear. 

•Place your cursor at the end of the text appearing in the space marked Variable Value . (Use the End key to ensure that your cursor is positioned at the very end of the text in this space.) Then enter the complete path name of your MySQL bin  directory (for example, C:\Program Files\MySQL\MySQL Server 8.0\bin ), and there should be a semicolon separating this path from any values present 

