8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

2.3.5 Windows 安装后过程2.3.5 Windows Postinstallation Procedures

GUI 工具可以执行本节中描述的大部分任务,包括:GUI tools exist that perform most of the tasks described in this section, including:

如有必要,初始化数据目录并创建 MySQL 授权表。 MySQL Configurator 执行的 Windows 安装操作可以自动初始化数据目录。对于从 ZIP 存档包安装,请按照第 2.9.1 节“初始化数据目录”中的说明初始化数据目录。If necessary, initialize the data directory and create the MySQL grant tables. Windows installation operations performed by MySQL Configurator can initialize the data directory automatically. For installation from a ZIP Archive package, initialize the data directory as described at Section 2.9.1, “Initializing the Data Directory”.

关于密码,如果您使用 MySQL 配置器配置 MySQL,则可能已经为初始 root 分配了密码帐户。 (请参阅第 2.3.2 节“配置:使用 MySQL 配置器”。)否则,请使用第 2.9.4 节“保护初始 MySQL 帐户”中给出的密码分配过程。初始 MySQL 帐户”。Regarding passwords, if you configured MySQL using the MySQL Configurator, you may have already assigned a password to the initial root account. (See Section 2.3.2, “Configuration: Using MySQL Configurator”.) Otherwise, use the password-assignment procedure given in Section 2.9.4, “Securing the Initial MySQL Account”.

在分配密码之前,您可能需要尝试运行一些客户端程序以确保您可以连接到服务器并且服务器运行正常。确保服务器正在运行(请参阅第 2.3.3.5 节“首次启动服务器”)。您还可以设置在 Windows 启动时自动运行的 MySQL 服务(请参阅第 2.3.3.8 节“将 MySQL 作为 Windows 服务启动”)。Before assigning a password, you might want to try running some client programs to make sure that you can connect to the server and that it is operating properly. Make sure that the server is running (see Section 2.3.3.5, “Starting the Server for the First Time”). You can also set up a MySQL service that runs automatically when Windows starts (see Section 2.3.3.8, “Starting MySQL as a Windows Service”).

这些说明假定您的当前位置是 MySQL 安装目录,并且它有一个包含 MySQL 程序的 bin 子目录在这里使用。如果不是这样,请相应地调整命令路径名称。These instructions assume that your current location is the MySQL installation directory and that it has a bin subdirectory containing the MySQL programs used here. If that is not true, adjust the command path names accordingly.

如果您使用 MSI 安装 MySQL,则默认安装目录为 C:\Program Files\MySQL\MySQL Server 8.4:If you installed MySQL using the MSI, the default installation directory is C:\Program Files\MySQL\MySQL Server 8.4:

C:\> cd "C:\Program Files\MySQL\MySQL Server 8.4"

从 ZIP 存档安装的常见安装位置为 C:\mysql:A common installation location for installation from a ZIP archive is C:\mysql:

C:\> cd C:\mysql

或者,将 bin 目录添加到您的 PATH 环境变量设置。这使您的命令解释器能够正确找到 MySQL 程序,以便您可以通过仅键入程序名称而不是路径名称来运行程序。请参阅第 2.3.3.7 节“自定义 MySQL 工具的路径”。Alternatively, add the bin directory to your PATH environment variable setting. That enables your command interpreter to find MySQL programs properly, so that you can run a program by typing only its name, not its path name. See Section 2.3.3.7, “Customizing the PATH for MySQL Tools”.

在服务器运行时,发出以下命令以验证是否可以从服务器检索信息。输出应与此处显示的类似。With the server running, issue the following commands to verify that you can retrieve information from the server. The output should be similar to that shown here.

使用 mysqlshow 查看存在哪些数据库:Use mysqlshow to see what databases exist:

C:\> bin\mysqlshow
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+

已安装数据库的列表可能有所不同,但始终至少包含 mysql 和 information_schema.The list of installed databases may vary, but always includes at least mysql and information_schema.

如果正确的 MySQL 帐户不存在,上述命令(以及其他 MySQL 程序的命令,例如 mysql)可能无法工作。例如,程序可能会因错误而失败,或者您可能无法查看所有数据库。如果您使用 MySQL 配置器配置 MySQL,则会使用您提供的密码自动创建 root 用户。在这种情况下,您应该使用 -u root 和 -p 选项。 (如果您已经保护了初始 MySQL 帐户,则必须使用这些选项。)使用 -p,客户端程序会提示输入 root 密码。例如:The preceding command (and commands for other MySQL programs such as mysql) may not work if the correct MySQL account does not exist. For example, the program may fail with an error, or you may not be able to view all databases. If you configured MySQL using MySQL Configurator, the root user is created automatically with the password you supplied. In this case, you should use the -u root and -p options. (You must use those options if you have already secured the initial MySQL accounts.) With -p, the client program prompts for the root password. For example:

C:\> bin\mysqlshow -u root -p
Enter password: (enter root password here)
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+

如果指定数据库名称,mysqlshow 显示数据库中的表列表:If you specify a database name, mysqlshow displays a list of the tables within the database:

C:\> bin\mysqlshow mysql
Database: mysql
+---------------------------+
|          Tables           |
+---------------------------+
| columns_priv              |
| component                 |
| db                        |
| default_roles             |
| engine_cost               |
| func                      |
| general_log               |
| global_grants             |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| ndb_binlog_index          |
| password_history          |
| plugin                    |
| procs_priv                |
| proxies_priv              |
| role_edges                |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+

使用 mysql 程序,用于从 mysql 数据库中的表中选择信息:Use the mysql program to select information from a table in the mysql database:

C:\> bin\mysql -e "SELECT User, Host, plugin FROM mysql.user" mysql
+------+-----------+-----------------------+
| User | Host      | plugin                |
+------+-----------+-----------------------+
| root | localhost | caching_sha2_password |
+------+-----------+-----------------------+

有关 mysql 和 mysqlshow,请参阅第 6.5.1 节“mysql — MySQL 命令行客户端” 和 第 6.5.6 节“mysqlshow — 显示数据库、表和列信息”。For more information about mysql and mysqlshow, see Section 6.5.1, “mysql — The MySQL Command-Line Client”, and Section 6.5.6, “mysqlshow — Display Database, Table, and Column Information”.