PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.3Kb
Man Pages (Zip) - 402.5Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
Security in MySQL
Starting and Stopping MySQL
MySQL and Linux/Unix
MySQL and Windows
MySQL and macOS
MySQL and Solaris
Building MySQL from Source
MySQL Restrictions and Limitations
MySQL Partitioning
MySQL Tutorial
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL NDB Cluster 8.0
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 usingNET commands, or with the graphicalServices utility. Generally, to install MySQL as a Windows service you should be logged in using an account that has administrator rights.
TheServices utility (the WindowsService Control Manager) can be found in the Windows Control Panel. To avoid conflicts, it is advisable to close theServices 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 If the MySQLroot user account has a password, you need to invokemysqladmin with the-p option and supply the password when prompted.
This command invokes the MySQL administrative utilitymysqladmin to connect to the server and tell it to shut down. The command connects as the MySQLroot user, which is the default administrative account in the MySQL grant system.
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:
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld" --installThe 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 MySQLbin directory to your Windows systemPATH environment variable:
On the Windows desktop, right-click theMy Computer icon, and selectProperties.
Next select theAdvanced tab from theSystem Properties menu that appears, and click theEnvironment Variables button.
UnderSystem Variables, selectPath, and then click theEdit button. TheEdit System Variable dialogue should appear.
Place your cursor at the end of the text appearing in the space markedVariable Value. (Use theEnd 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
bindirectory (for example,C:\Program Files\MySQL\MySQL Server 8.0\bin), and there should be a semicolon separating this path from any values present in this field. Dismiss this dialogue, and each dialogue in turn, by clickingOK until all of the dialogues that were opened have been dismissed. You should now be able to invoke any MySQL executable program by typing its name at the DOS prompt from any directory on the system, without having to supply the path. This includes the servers, themysql client, and all MySQL command-line utilities such asmysqladmin andmysqldump.You should not add the MySQL
bindirectory to your WindowsPATHif you are running multiple MySQL servers on the same machine.
You must exercise great care when editing your systemPATH by hand; accidental deletion or modification of any portion of the existingPATH value can leave you with a malfunctioning or even unusable system.
The following additional arguments can be used when installing the service:
You can specify a service name immediately following the
--installoption. The default service name isMySQL.If a service name is given, it can be followed by a single option. By convention, this should be
--defaults-file=to specify the name of an option file from which the server should read options when it starts.file_nameThe use of a single option other than
--defaults-fileis possible but discouraged.--defaults-fileis more flexible because it enables you to specify multiple startup options for the server by placing them in the named option file.You can also specify a
--local-serviceoption following the service name. This causes the server to run using theLocalServiceWindows account that has limited system privileges. If both--defaults-fileand--local-serviceare given following the service name, they can be in any order.
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:
If the service-installation command specifies no service name or the default service name (
MySQL) following the--installoption, the server uses the service name ofMySQLand reads options from the[mysqld]group in the standard option files.If the service-installation command specifies a service name other than
MySQLfollowing the--installoption, the server uses that service name. It reads options from the[mysqld]group and the group that has the same name as the service in the standard option files. This enables you to use the[mysqld]group for options that should be used by all MySQL services, and an option group with the service name for use by the server installed with that service name.If the service-installation command specifies a
--defaults-fileoption after the service name, the server reads options the same way as described in the previous item, except that it reads options only from the named file and ignores the standard option files.
As a more complex example, consider the following command:
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\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, and only from the named file.
On Windows, if the server is started with the--defaults-file and--install options,--install must be first. Otherwise,mysqld.exe attempts to start the MySQL server.
You can also specify options as Start parameters in the WindowsServices utility before you start the MySQL service.
Finally, before trying to start the MySQL service, make sure the user variables%TEMP% and%TMP% (and also%TMPDIR%, if it has ever been set) for the operating system user who is to run the service are pointing to a folder to which the user has write access. The default user for running the MySQL service isLocalSystem, and the default value for its%TEMP% and%TMP% isC:\Windows\Temp, a directoryLocalSystem has write access to by default. However, if there are any changes to that default setup (for example, changes to the user who runs the service or to the mentioned user variables, or the--tmpdir option has been used to put the temporary directory somewhere else), the MySQL service might fail to run because write access to the temporary directory has not been granted to the proper user.
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 theServices utility, or by using ansc startmysqld_service_name orNET STARTmysqld_service_name command.SC andNET commands are not case-sensitive.
When run as a service,mysqld has no access to a console window, so no messages can be seen there. Ifmysqld 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,C:\Program Files\MySQL\MySQL Server 8.0\data). It is the file with a suffix of.err.
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 theServices utility, thesc stopmysqld_service_name command, theNET STOPmysqld_service_name command, or themysqladmin shutdown command.
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--install-manual option rather than the--install option:
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld" --install-manualRemoving the service
To remove a server that is installed as a service, first stop it if it is running by executingSC STOPmysqld_service_name orNET STOPmysqld_service_name. Then useSC DELETEmysqld_service_name to remove it:
C:\> SC DELETE mysql Alternatively, use themysqld--remove option to remove the service.
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld" --removeIfmysqld is not running as a service, you can start it from the command line. For instructions, seeSection 2.3.4.6, “Starting MySQL from the Windows Command Line”.
If you encounter difficulties during installation, seeSection 2.3.5, “Troubleshooting a Microsoft Windows MySQL Server Installation”.
For more information about stopping or removing a Windows service, seeSection 7.8.2.2, “Starting Multiple MySQL Instances as Windows Services”.
PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.3Kb
Man Pages (Zip) - 402.5Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
Security in MySQL
Starting and Stopping MySQL
MySQL and Linux/Unix
MySQL and Windows
MySQL and macOS
MySQL and Solaris
Building MySQL from Source
MySQL Restrictions and Limitations
MySQL Partitioning
MySQL Tutorial
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL NDB Cluster 8.0