This section gives a general overview of starting the MySQL server. The following sections provide more specific information for starting the MySQL server from the command line or as a Windows service.本节提供启动MySQL服务器的一般概述。以下部分提供了从命令行或作为Windows服务启动MySQL服务器的更具体信息。
The information here applies primarily if you installed MySQL using the 如果您使用noinstall
version, or if you wish to configure and test MySQL manually rather than with the MySQL Installer.noinstall
版本安装MySQL,或者您希望手动配置和测试MySQL,而不是使用MySQL安装程序,则此处的信息主要适用。
The examples in these sections assume that MySQL is installed under the default location of 这些部分中的示例假设MySQL安装在默认位置C:\Program Files\MySQL\MySQL Server 8.0
. Adjust the path names shown in the examples if you have MySQL installed in a different location.C:\Program Files\MySQL\MySQL Server 8.0
下。如果MySQL安装在其他位置,请调整示例中显示的路径名。
Clients have two options. They can use TCP/IP, or they can use a named pipe if the server supports named-pipe connections.客户端有两种选择。它们可以使用TCP/IP,如果服务器支持命名管道连接,也可以使用命名管道。
MySQL for Windows also supports shared-memory connections if the server is started with the 如果服务器在启用shared_memory
system variable enabled. shared_memory
系统变量的情况下启动,MySQL for Windows也支持共享内存连接。Clients can connect through shared memory by using the 客户端可以使用--protocol=MEMORY
option.--protocol=MEMORY
选项通过共享内存进行连接。
For information about which server binary to run, see Section 2.3.4.3, “Selecting a MySQL Server Type”.有关运行哪个服务器二进制文件的信息,请参阅第2.3.4.3节,“选择MySQL服务器类型”。
Testing is best done from a command prompt in a console window (or “DOS window”). 测试最好在控制台窗口(或“DOS窗口”)的命令提示符下进行。In this way you can have the server display status messages in the window where they are easy to see. If something is wrong with your configuration, these messages make it easier for you to identify and fix any problems.通过这种方式,您可以让服务器在易于查看的窗口中显示状态消息。如果您的配置出现问题,这些消息将使您更容易识别和修复任何问题。
The database must be initialized before MySQL can be started. For additional information about the initialization process, see Section 2.10.1, “Initializing the Data Directory”.必须先初始化数据库,然后才能启动MySQL。有关初始化过程的更多信息,请参阅第2.10.1节,“初始化数据目录”。
To start the server, enter this command:要启动服务器,请输入以下命令:
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld" --console
For a server that includes 对于包含InnoDB
support, you should see the messages similar to those following as it starts (the path names and sizes may differ):InnoDB
支持的服务器,您应该在启动时看到类似于以下消息的消息(路径名称和大小可能不同):
InnoDB: The first specified datafile c:\ibdata\ibdata1 did not exist: InnoDB: a new database to be created! InnoDB: Setting file c:\ibdata\ibdata1 size to 209715200 InnoDB: Database physically writes the file full: wait... InnoDB: Log file c:\iblogs\ib_logfile0 did not exist: new to be created InnoDB: Setting log file c:\iblogs\ib_logfile0 size to 31457280 InnoDB: Log file c:\iblogs\ib_logfile1 did not exist: new to be created InnoDB: Setting log file c:\iblogs\ib_logfile1 size to 31457280 InnoDB: Log file c:\iblogs\ib_logfile2 did not exist: new to be created InnoDB: Setting log file c:\iblogs\ib_logfile2 size to 31457280 InnoDB: Doublewrite buffer not found: creating new InnoDB: Doublewrite buffer created InnoDB: creating foreign key constraint system tables InnoDB: foreign key constraint system tables created 011024 10:58:25 InnoDB: Started
When the server finishes its startup sequence, you should see something like this, which indicates that the server is ready to service client connections:当服务器完成其启动序列时,您应该看到这样的内容,这表明服务器已准备好为客户端连接提供服务:
mysqld: ready for connections Version: '8.0.25' socket: '' port: 3306
The server continues to write to the console any further diagnostic output it produces. You can open a new console window in which to run client programs.服务器继续向控制台写入它产生的任何进一步的诊断输出。您可以打开一个新的控制台窗口,在其中运行客户端程序。
If you omit the 如果省略--console
option, the server writes diagnostic output to the error log in the data directory (C:\Program Files\MySQL\MySQL Server 8.0\data
by default). --console
选项,服务器会将诊断输出写入数据目录中的错误日志(默认情况下为C:\Program Files\MySQL\MySQL server 8.0\data
)。The error log is the file with the 错误日志是扩展名为.err
extension, and may be set using the --log-error
option..err
的文件,可以使用--log-error
选项进行设置。
The initial MySQL授权表中的初始根帐户没有密码。启动服务器后,您应该使用第2.10.4节,“保护初始MySQL帐户”中的说明为其设置密码。root
account in the MySQL grant tables has no password. After starting the server, you should set up a password for it using the instructions in Section 2.10.4, “Securing the Initial MySQL Account”.