2.3.4.6 Starting MySQL from the Windows Command Line从Windows命令行启动MySQL

The MySQL server can be started manually from the command line. This can be done on any version of Windows.MySQL服务器可以从命令行手动启动。这可以在任何版本的Windows上完成。

To start the mysqld server from the command line, you should start a console window (or DOS window) and enter this command:要从命令行启动mysqld服务器,您应该启动一个控制台窗口(或“DOS窗口”)并输入以下命令:

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

The path to mysqld may vary depending on the install location of MySQL on your system.mysqld的路径可能因MySQL在系统上的安装位置而异。

You can stop the MySQL server by executing this command:您可以通过执行以下命令来停止MySQL服务器:

C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqladmin" -u root shutdown
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.如果MySQLroot用户帐户有密码,则需要使用-p选项调用mysqladmin,并在提示时提供密码。

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.这个命令调用MySQL管理实用程序mysqladmin来连接到服务器并告诉它关闭。该命令以MySQL root用户的身份连接,MySQL root用户是MySQL授予系统中的默认管理帐户。

Note注意

Users in the MySQL grant system are wholly independent from any operating system users under Microsoft Windows.MySQL授权系统中的用户完全独立于Microsoft Windows下的任何操作系统用户。

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. 如果mysqld没有启动,请检查错误日志,查看服务器是否在其中写入了任何消息来指示问题的原因。By default, the error log is located in the C:\Program Files\MySQL\MySQL Server 8.0\data directory. 默认情况下,错误日志位于C:\Program Files\MySQL\MySQL Server 8.0\data目录中。It is the file with a suffix of .err, or may be specified by passing in the --log-error option. 它是后缀为.err的文件,也可以通过传递--log-error选项来指定。Alternatively, you can try to start the server with the --console option; in this case, the server may display some useful information on the screen to help solve the problem.或者,您可以尝试使用--console选项启动服务器;在这种情况下,服务器可以在屏幕上显示一些有用的信息来帮助解决问题。

The last option is to start mysqld with the --standalone and --debug options. 最后一个选项是使用--standalone--debug选项启动mysqldIn this case, mysqld writes a log file C:\mysqld.trace that should contain the reason why mysqld doesn't start. 在这种情况下,mysqld会编写一个日志文件C:\mysqld.trace,其中应该包含mysqld没有启动的原因。See Section 5.9.4, “The DBUG Package”.请参阅第5.9.4节,“DBUG软件包”

Use mysqld --verbose --help to display all the options that mysqld supports.使用mysqld --verbose --help显示mysqld支持的所有选项。