
目录
第11题
Which four are types of information stored in the MySQL data dictionary? (Choose four.)
plain
C)access control lists [正确]
D)view definitions [正确]
E)server runtime configuration [错误]
A)performance metrics [错误]
F)server configuration rollback [错误]
H)InnoDB buffer pool LRU management data [错误]
B)table definitions [正确]
G)stored procedure definitions[正确]
题目分析
这道题目考查的是:MySQL 数据字典中存储的信息类型。
- 什么是MySQL数据字典?
MySQL
从8.0开始 引入了统一的数据字典,用来集中管理数据库对象的元数据(metadata),例如表、列、索引、视图、触发器、权限等。
这些信息存储在系统表中(如 mysql.*
),并且是持久化存储。
- 分析选项
access control lists
(ACL,访问控制列表):用户、角色、权限信息(如mysql.user
)都属于数据字典管理的对象。数据字典会记录谁有权限访问哪些数据库对象。view definitions
(视图定义):CREATE VIEW
创建的视图,其 SQL 定义被保存在数据字典中。包括依赖的表、列等信息。server runtime configuration
(服务器运行时配置):运行时配置(如innodb_buffer_pool_size
,max_connections
)是在内存中动态调整的,不属于元数据。它们不会存入数据字典,只能通过配置文件或命令设置。performance metrics
(性能指标):这类信息(如查询次数、慢查询数)存储于performance_schema
中,为内存结构,非元数据。不属于数据字典的管理范畴。server configuration rollback
(服务器配置回滚):MySQL 本身没有配置回滚机制,这类功能属于配置管理工具范畴,不是数据库内部元数据。自然也不在数据字典中。InnoDB buffer pool LRU management data
:属于运行时内存结构,用于页面淘汰管理,完全不属于数据字典。属于 InnoDB 内部机制。table definitions
(表定义):表名、列、类型、索引、约束等信息都是数据库的核心元数据,全部保存在数据字典中。比如mysql.tables
,information_schema.tables
都会引用这些。stored procedure definitions
(存储过程定义)存储过程、函数定义属于数据库对象,其定义 SQL 会存储在数据字典中。包括参数、返回值类型、定义语句等。
正确答案
plain
B) table definitions
C) access control lists
D) view definitions
G) stored procedure definitions
第12题
Choose two.Examine this SQL statement
bash
mysql> GRANT r_read@localhost TO mark WITH ADMIN OPTION;
Which two are true?
bash
A) Mark can grant the privileges assigned to the r_read@localhost role to another user. [错误]
D) Mark must connect from localhost to activate the r_read@localhost role. [错误]
B) Mark can grant the r_read@localhost role to another user. [正确]
D) server runtime configuration [错误]
E) Mark can revoke the r_read@localhost role from another role. [正确]
F) ADMIN OPTION allows Mark to drop the role. [错误]
C) ADMIN OPTION causes the role to be activated by default. [错误]
题目分析
这道题目考察的是 MySQL 中 角色管理(Role Management) 与 GRANT ... WITH ADMIN OPTION
的行为,重点是理解角色授权及其"管理选项"的影响。
sql
GRANT r_read@localhost TO mark WITH ADMIN OPTION;
含义如下:
- 把角色
r_read@localhost
赋予用户mark
- 并使用了
WITH ADMIN OPTION
,这表示:mark
可以将这个角色授予别人(即:有角色"管理权限")
选项分析:
- 选项A:"Mark可以将分配给r_read@localhost角色的权限授予另一个用户。 " 这里可能有混淆,因为
ADMIN OPTION
允许授予角色本身,而不是角色的权限。角色的权限是已经定义好的,用户无法修改角色的权限,只能授予或撤销角色。因此,选项A可能不正确,因为Mark不能直接分配角色的权限,只能分配角色。 - 选项B:"Mark可以将r_read@localhost角色授予另一个用户。 " 这是正确的,因为
ADMIN OPTION
允许用户将该角色授予其他用户或角色。所以B是对的。 - 选项D:"Mark必须从localhost连接才能激活
r_read@localhost
角色。" 角色是否激活通常与用户的会话设置有关,而不是连接的主机。因此,选项D可能不正确 - 选项E:"Mark可以撤销另一个角色的r_read@localhost角色 。" 如果
Mark
有ADMIN OPTION
,那么他可以撤销其他用户或角色的该角色,所以E是正确的。 - 选项F:"ADMIN OPTION允许Mark删除该角色。" 删除角色需要DROP ROLE权限,而ADMIN OPTION只是允许授予或撤销角色,并不包含删除权限,因此F不正确。
- 选项C:"ADMIN OPTION导致该角色默认被激活。" 默认激活角色由其他参数控制,如SET DEFAULT ROLE,与ADMIN OPTION无关,所以C错误。
正确答案
sql
B) Mark can grant the r_read@localhost role to another user.
E) Mark can revoke the r_read@localhost role from another role.
第13题
Which two statements are true about general tablespaces?
bash
B)Dropping a table from a general tablespace releases the space back to the operating system. [错误]
E)A general tablespace can have multiple data files. [错误]
A)General tablespaces support temporary tables. [错误]
C)A new table can be created explicitly in a general tablespace. [正确]
D)An existing table can be moved into a general tablespace. [正确]
题目分析
这道题考察的是MySQL
中General Tablespace
(通用表空间) 的特性,属于InnoDB
存储引擎的内容。
- 什么是
General Tablespace
?
General Tablespace
是一种由用户创建、支持 多个表 的 共享表空间。
不像 innodb_file_per_table
模式每个表一个表空间,General Tablespace
可存放多个表。
它具有以下主要特性:
- 可以显式创建并指定表属于哪个表空间。
- 支持多个表(
MyISAM
不支持)。 - 表被删除后空间 不会自动释放给操作系统。
通常保留为 .ibd
类型文件。
逐项分析选项:
A new table can be created explicitly in a general tablespace
.
可以使用如下语句创建一个属于General Tablespace
的新表:
sql
CREATE TABLE t1 (
id INT
) TABLESPACE ts1;
An existing table can be moved into a general tablespace.
从MySQL 8.0
起,使用 ALTER TABLE ... TABLESPACE
可以将现有表迁移到一个 General Tablespace:
sql
ALTER TABLE t1 TABLESPACE ts1;
General tablespaces support temporary tables
.
General Tablespace
仅支持 持久表(permanent tables),不支持 临时表(temporary tables)。
临时表应放在 innodb_temp_tablespace
中。
Dropping a table from a general tablespace releases the space back to the operating system.
表被删除后,空间不会归还给操作系统,但可以被同一个表空间中的其他表重用。释放到表空间内部,不会归还给OS
。
A general tablespace can have multiple data files
.
一个 General Tablespace
只能对应一个数据文件,不能多个。
正确答案
sql
C) A new table can be created explicitly in a general tablespace.
D) An existing table can be moved into a general tablespace
第14题
Which three methods are part of a 'scale up' approach to capacity planning?
sql
E)adding more storage to your disk array [正确]
G)adding a new node to InnoDB Cluster [错误]
D)adding more RAM [正确]
C)adding a replication slave [错误]
F)sharding the server into a parallel server farm [错误]
B)adding more CPU power [正确]
A)adding additional MySQL servers to the existing host [错误]
题目分析
这道题考察的是 容量规划(capacity planning) 中的 "scale up" 方法,也就是 纵向扩展。
- 什么是 Scale Up?
Scale Up(纵向扩展):指通过提升单个服务器的硬件配置来提升性能,如增加 CPU、内存、硬盘等。
相对概念:Scale Out(横向扩展):通过增加更多节点或服务器来提升整体系统容量和可用性。
- 逐项分析选项:
Adding more CPU power
:是典型的scale up
做法,增加CPU
性能来提高处理能力。Adding more RAM
:增加内存同样是纵向扩展的方式之一,有助于缓存更多数据,减少磁盘I/O
。Adding more storage to your disk array
:增加硬盘空间或更换更快的磁盘属于 scale up,提升存储容量或IOPS
性能。
以上三个答案都是正确的。
Adding additional MySQL servers to the existing host
:同一台主机部署多个 MySQL 实例不是有效的 scale up 方法,通常这样做会导致资源竞争,反而降低性能。Adding a replication slave
:这属于横向扩展(scale out),通过副本分担读请求。Sharding the server into a parallel server farm
:分片是 scale out 的典型策略,将数据拆分到多个服务器。Adding a new node to InnoDB Cluster
:增加节点属于横向扩展(scale out),用于提高可用性和负载均衡。
正确答案
sql
B) Adding more CPU power
D) Adding more RAM
E) Adding more storage to your disk array
第15题
Choose three.A user wants to connect without entering his or her username and password on the
Linux command prompt.Which three locations can be used to store the user's mysql credentials to
satisfy this requirement?
sql
A)$HOME/.mysqlrc file [错误]
F)$MYSQL_HOME/my.cnf file [错误]
C)DATADIR/mysqld-auto.cnf file [错误]
B)/etc/my.cnf file [正确]
E)$HOME/.mylogin.cnf file [正确]
G)$HOME/.mysql/auth/login file [错误]
D)$HOME/.my.cnf file [正确]
题目分析
这道题考察的是:MySQL
在 Linux 系统下支持哪些位置用于存储用户的登录凭据(用户名和密码),以便用户在命令行使用 mysql
客户端时可以免输入。
MySQL 支持的三种方式存储凭据
~/.my.cnf
文件(明文)
路径: $HOME/.my.cnf
格式:
properties
[client]
user=myuser
password=mypassword
风险: 明文存储,建议设置文件权限为 600。
~/.mylogin.cnf
文件(加密)
路径: $HOME/.mylogin.cnf
特点:使用 mysql_config_editor
创建,密码加密存储。更安全,是推荐做法。
/etc/my.cnf
或其他 MySQL 配置路径
路径: /etc/my.cnf
说明:系统级配置文件,可以为所有用户提供默认账号密码。但存储密码也会面临安全风险。
- 其他选项分析
选项 | 说明 | 结论 |
---|---|---|
$HOME/.mysqlrc |
❌ 非 MySQL 支持的标准配置文件名 |
❌错误 |
DATADIR/mysqld-auto.cnf |
❌ 用于内部 server 配置,如 server UUID ,不是客户端凭据 |
❌错误 |
$MYSQL_HOME/my.cnf |
❌ $MYSQL_HOME 非标准变量,MySQL 不会默认查找 |
❌错误 |
$HOME/.mysql/auth/login |
❌ 并非 MySQL 标准凭据存储路径 |
❌错误 |
正确答案
sql
B) /etc/my.cnf
D) $HOME/.my.cnf
E) $HOME/.mylogin.cnf
第16题
choose two.Examine the modified output:
sql
mysql> SHOW SLAVE STATUS\\G
******************1. row********************
Slave_IO_Running:Yes
Slave_SQL_Running:Yes
Seconds_Behind_Master:1612
Seconds_Behind_Master value is steadily growing. What are two possible causes?
sql
B)This value shows only I/O latency and is not indicative of the size of the transaction queue. [错误]
A)The master is producing a large volume of events in parallel but the slave is processing them serially. [正确]
C)One or more large tables do not have primary keys. [错误]
E)The parallel slave threads are experiencing lock contention.[正确]
D)The master is most probably too busy to transmit data and the slave needs to wait for more data. [错误]
题目分析
当 Seconds_Behind_Master
不断增长,但 Slave_IO_Running=Yes
且 Slave_SQL_Running=Yes
时,说明主从之间网络和 I/O 都正常,从服务器的 SQL 应用速度跟不上主服务器的写入速度。以下两种情况最常见:
- 主服务器并行生成大量事件,而从服务器串行处理
- 如果是单线程复制(MySQL 5.6 之前),SQL 线程必然只能串行应用所有事件,即使主库并行写入也无法并行回放;
- 即便是支持并行复制的版本,事务之间有依赖关系时也会退化为串行应用。
- 结果:主库写入速率 > 从库应用速率 → 复制延迟持续攀升。
- 对应选项 A。
- 并行从线程在应用事务时发生锁争用
- 并行复制场景下,多
SQL
线程并行拉取并行执行事务,但如果它们操作同一行或同一页数据,就会产生InnoDB
锁竞争; - 争锁会让部分线程被阻塞,无法并行处理,导致整体应用速度下降;
- 结果同样是从库追不上主库,延迟不断增长。
- 对应选项 E。
- 并行复制场景下,多
排除其他选项简析:
- B)
Seconds_Behind_Master
不仅反映I/O延迟,还包括SQL
应用延迟。 - C) 缺少主键的表在
InnoDB
上确实会导致全表扫描,但通常会报错或严重影响单表复制,而非稳定增长的延迟。 - D) 如果主库过于繁忙导致传输慢,从库的
I/O
线程常常会变成No
(无法读取 binlog),而题中I/O线程仍然是Yes
,说明主从之间数据流正常。
正确答案
sql
A) The master is producing a large volume of events in parallel but the slave is processing them serially.
E) The parallel slave threads are experiencing lock contention.
第17题
Choose two.Which two are true about binary logs used in asynchronous replication?
bash
A)The master connects to the slave and initiates log transfer. [错误]
B)They contain events that describe all queries run on the master. [错误]
D)They are pulled from the master to the slave. [正确]
C)They contain events that describe database changes on the master. [正确]
E)They contain events that describe only administrative commands run on the master. [错误]
题目分析
这道题考查的是MySQL
异步复制asynchronous replication
中 binary log
(二进制日志) 的特性。我们逐个分析选项:
They contain events that describe database changes on the master.
二进制日志记录了对数据库的更改操作,例如INSERT
、UPDATE
、DELETE
等。它们不会记录只读查询(如SELECT
),而是只记录影响数据状态的事务。They are pulled from the master to the slave.
在异步复制中,是从库主动连接主库 并拉取binary log
内容。即slave
通过I/O
线程连接主库的replication log dump
线程,获取并写入relay log
。
以上两个答案为正确。
The master connects to the slave and initiates log transfer.
:异步复制是slave
主动发起连接(典型的是CHANGE MASTER TO
配置的主库地址),主库不会主动连接从库。They contain events that describe all queries run on the master.
:Binary log
不记录所有查询,仅记录那些 修改了数据的语句。例如:SELECT
查询不会记录,INSERT
会记录。They contain events that describe only administrative commands run on the master.
:Binary log
中可能包含一些管理命令(如CREATE USER
),但它们主要记录的是 数据更改事件,而非"仅仅是"管理命令。
正确答案:
bash
C) They contain events that describe database changes on the master.
D) They are pulled from the master to the slave.
第18题
You have appropriate privileges and are about to shut down a running MySQL server process on
Oracle Linux 7.Which three are valid methods that will shut down the MySQL server?
bash
E)mysqld_safe --shutdown [错误]
A)mysqld_safe -S /tmp/mysql.sock SHUTDOWN [错误]
B)kill mysqld_safe [错误]
F)systemctl stop mysqld [正确]
G)mysql> SHUTDOWN; [正确]
D)mysql -S /tmp/mysql.sock --shutdown [错误]
C)mysqladmin shutdown [正确]
题目分析
这道题考查的是在Oracle Linux 7
上安全关闭MySQL
服务的几种有效方式。你拥有适当的权限(如 root 或具有 SHUTDOWN 权限的用户),现在我们来逐个分析选项,找出 三种有效关闭 MySQL 服务的方法。
mysqladmin shutdown
:✅ 正确。
这是标准、安全的关闭 MySQL 的命令:
bash
mysqladmin -u root -p shutdown
它通过客户端与MySQL
服务通信,请求有序关机。
systemctl stop mysqld
:✅ 正确。
在 Oracle Linux 7(使用 systemd)中,这是一种推荐方式:
bash
sudo systemctl stop mysqld
会优雅地停止服务,执行与 mysqladmin shutdown
类似的行为。
mysql> SHUTDOWN;
✅ 正确。
如果你已经连接到了mysql
客户端,并拥有SHUTDOWN
权限,可以直接执行:
sql
mysql> SHUTDOWN;
会立即请求服务器有序关闭。
mysqld_safe -S /tmp/mysql.sock SHUTDOWN
:❌ 错误。
mysqld_safe
是MySQL
的安全启动脚本,并不接受 SHUTDOWN
参数。这个命令格式错误。
kill mysqld_safe
:❌ 错误。
mysqld_safe
是 wrapper,它本身不是真正的服务进程,杀掉它不一定能杀掉mysqld,并且也不是优雅关闭。而且使用 kill
杀进程是不推荐的关闭方式,可能导致数据未刷盘等风险。
mysql -S /tmp/mysql.sock --shutdown
❌ 错误。
mysql
客户端并没有 --shutdown
参数,这是无效参数。
mysqld_safe --shutdown
❌ 错误。
同样无效,mysqld_safe
没有 --shutdown
这个选项。
正确答案
sql
✅ C) mysqladmin shutdown
✅ F) systemctl stop mysqld
✅ G) mysql> SHUTDOWN;
第19题
Choose two.Examine this MySQL Shell command:
sql
dba.rebootClusterFromCompleteOutage ()
Which two statements are true?
sql
E)lt reconfigures InnoDB Cluster if the cluster was stopped. [错误]
D)lt performs InnoDB Cluster instances rolling restart. [错误]
A)lt stops and restarts all InnoDB Cluster instances and initializes the metadata. [错误]
F)lt picks the minimum number of instances necessary to rebuild the quorum and reconfiquresInnoDB Cluster.[正确]
C)lt is not mandatory that all instances are running and reachable before running the command. [正确]
B)lt only stops and restarts all InnoDB Cluster instances.[错误]
G)lt only starts all InnoDB Cluster instances.[错误]
题目分析
C) 无需所有实例在线
- 原因 :
dba.rebootClusterFromCompleteOutage()
专为集群完全宕机后的恢复设计,仅需部分实例(满足多数派)即可重建集群。 - 操作逻辑:自动检测存活实例,优先选择数据最新的节点重组集群,无需手动启动所有节点。
F) 选取最少数实例重建法定人数
- 原因:通过最小化存活实例数量(如3节点集群中至少2个)恢复多数派(Quorum),确保集群一致性。
- 关键步骤 :
- 识别拥有最新
GTID
的实例。 - 联合其他存活实例形成新集群,重新配置元数据。
- 识别拥有最新
排除其他选项的原因
- E) 停止后重新配置集群:描述模糊,未明确"重新配置"具体指代,且命令核心目标是恢复而非单纯配置。
- D) 滚动重启:该命令用于宕机恢复,非逐步重启(滚动重启需各节点依次操作,与此场景不符)。
- A/B/G) 启停所有实例:命令不主动停止实例,而是基于已停止的集群进行恢复。
正确答案
sql
lt performs InnoDB Cluster instances rolling restart.
lt is not mandatory that all instances are running and reachable before running the command.
第20题
Examine this command and output: (见下图) Which two options will improve thesecurity of the MySQL instance?

sql
D)Change the parent directory owner and group to mysql. [错误]
A)Remove the world read/execute privilege from the accounting directory. [正确]
F)Remove group read/write privileges from the private key.pem file. [正确]
E)Remove world read privileges from the server-cert.pem certificate file.[错误]
B)Remove world read privileges from the public key.pem file. [错误]
C)Change the group ownership of the mysql directory to the mysql user group. [错误]
题目分析
请查看下列命令与输出(见下图)。以下哪两项操作可以提升该 MySQL 实例的安全性?
A)从 accounting
目录中移除"全局可读/可执行"权限。
B)从 public_key.pem
文件中移除"全局可读"权限。
C)将 /var/lib/mysql/mysql
目录的所属用户组更改为 mysql
用户组。
D)将其父目录的所属用户和用户组都更改为 mysql
。
E)从 server-cert.pem
证书文件中移除"全局可读"权限。
F)从 private_key.pem
文件中移除"组可读/可写"权限。
选项A是正确。其他用户不应该有访问数据库相关目录的权限,尤其是包含业务数据的目录。这样可以防止未授权用户查看或进入该目录,提高安全性。这是一个有效且必要的措施。
选择F是正确。私钥文件(private_key.pem)必须严格保密,不应该让组或其他用户有读取权限。当前权限允许组用户读取,存在安全风险。修改为仅用户可读写是必要的,这是关键的安全措施。
正确答案
sql
A)Remove the world read/execute privilege from the accounting directory.
F)Remove group read/write privileges from the private key.pem file.