Oracle 为庆祝 MySQL 30 周年,截止到 2025.07.31 之前。所有人均可以免费考取原价245美元的MySQL OCP 认证。
从今天开始,将英文题库免费公布出来,并进行解析,帮助大家在一个月之内轻松通过OCP认证。

本期公布试题31~40
试题31:
Choose three.Which three statements are true about MySQL Enterprise Firewall?
F)It shows only notifications for blocked connections, which originated outside of your network's primary domain. [错误]
A)On Windows systems, it is controlled and managed using the Windows Internet Connection
Firewall control panel. [错误]
B)System tables named firewall_users and firewall_whitelist in the mysql database provide persistent
storage of firewall data. [正确]
C)It is available only in MySQL Enterprise versions. [正确]
E)Firewall functionality is dependent on SHA-256 and ANSI-specific functions built in to the
mysql.firewall table. [错误]
D)It provides INFORMATION_SCHEMA tables that enable views into firewall data. [正确]
解析
选择三个。关于MySQL企业防火墙,哪三个陈述是真实的?
language
F)It shows only notifications for blocked connections, which originated outside of your network's primary domain. [错误]
它仅显示来自您网络主域外部的阻止连接的通知。
错误,MySQL Enterprise Firewall 不会仅显示来自外部网络的拦截通知,它会记录所有被拦截的连接。
A)On Windows systems, it is controlled and managed using the Windows Internet Connection Firewall control panel. [错误]
在Windows系统中,它通过Windows互联网连接防火墙控制面板进行控制和管理。
错误,MySQL Enterprise Firewall 是 MySQL 服务器内置的功能,不依赖 Windows 防火墙控制面板管理
B)System tables named firewall_users and firewall_whitelist in the mysql database provide persistent storage of firewall data. [正确]
MySQL 数据库中的名为 firewall_users 和 firewall_whitelist 的系统表提供了防火墙数据的持久存储。
MySQL Enterprise Firewall 使用 mysql 数据库中的 firewall_users 和 firewall_whitelist 系统表来存储防火墙规则和用户白名单信息,确保数据持久化。
C)It is available only in MySQL Enterprise versions. [正确]
MySQL Enterprise Firewall 是 MySQL 企业版(Enterprise Edition)的专属功能,社区版(Community Edition)不支持。
E)Firewall functionality is dependent on SHA-256 and ANSI-specific functions built in to the mysql.firewall table. [错误]
错误,防火墙功能不依赖 SHA-256 或 ANSI 特定的函数,而是基于 SQL 模式匹配和规则引擎。
D)It provides INFORMATION_SCHEMA tables that enable views into firewall data. [正确]
它提供了INFORMATION_SCHEMA表,能够查看防火墙数据。
(如 INFORMATION_SCHEMA.MYSQL_FIREWALL_USERS 等),方便管理员查询防火墙的运行状态和配置信息。
试题32:
Choose two.Which two storage engines provide a view of the data consistent with the storage system at any moment?
E)NDB [正确]
A)InnoDB [正确]
D)MEMORY [错误]
B)ARCHIVE [错误]
C)MyISAM [错误]
解析
哪两个存储引擎提供与存储系统在任何时刻一致的数据视图?
language
NDB(MySQL Cluster 存储引擎)
NDB 是 MySQL Cluster 的默认存储引擎,支持事务(ACID)和多节点一致性。
它采用 分布式架构,确保所有节点在任何时刻都能提供一致的数据视图。
适用于高可用性和实时一致性的场景。
InnoDB
InnoDB 是 MySQL 的默认存储引擎,支持事务(ACID)和行级锁。
它使用 多版本并发控制(MVCC),确保即使在并发读写时,也能提供一致的数据视图。
适用于需要高并发和事务安全的场景。
错误选项解析:
D) MEMORY(内存引擎)
数据仅存储在内存中,不持久化,服务器重启后数据丢失,无法保证一致性。
B) ARCHIVE(归档引擎)
主要用于存储和压缩历史数据,不支持事务和即时一致性查询。
C) MyISAM
不支持事务,仅提供表级锁,无法保证高并发下的数据一致性。
试题33:
language
Choose threeWhich three are requirements for a secure MySQL Server environment?
B)Restrict the number of OS users that have access at the OS level. [正确]
C)Ensure appropriate file system privileges for OS users and groups. [正确]
D)Keep the entire software stack on one OS host. [正确]
A)Minimize the number of non-MySQL Server-related processes running on the server host. [错误]
F)Run MySQL server as the root user to prevent incorrect sudo settings. [错误]
E)Encrypt the file system to avoid needing exact file-system permissions. [错误]
解析
language
B)Restrict the number of OS users that have access at the OS level. [正确]
限制在操作系统级别拥有访问权限的用户数量。
减少能够直接访问 MySQL 服务器主机的操作系统用户数量,可以降低未授权访问的风险。
C)Ensure appropriate file system privileges for OS users and groups. [正确]
确保操作系统用户和组具有适当的文件系统权限。
D)Keep the entire software stack on one OS host. [正确]
将整个软件栈集中在一台 OS 主机上运行。
如果 MySQL 服务器、Web 应用、数据库管理工具等都运行在同一台主机上,可以降低网络攻击的风险(但可能影响高可用性)。
A)Minimize the number of non-MySQL Server-related processes running on the server host. [错误]
尽量减少服务器主机上运行的非 MySQL 相关进程
虽然合理,但不是强制要求。
某些服务器可能同时运行 Web 服务(如 Nginx/Apache)、监控工具(如 Prometheus),只要做好隔离和权限控制,不会直接影响 MySQL 安全。
F)Run MySQL server as the root user to prevent incorrect sudo settings. [错误]
以 root 用户运行 MySQL 以防止错误的 sudo 配置
严重错误! MySQL 绝对不应该以 root 用户运行,否则一旦 MySQL 被入侵,攻击者将获得整个服务器的 root 权限。
E)Encrypt the file system to avoid needing exact file-system permissions. [错误]
加密文件系统以避免精确的文件权限设置
错误逻辑。加密文件系统(如 LUKS、BitLocker)用于防止物理数据泄露,但 不能替代文件权限管理。
试题34:
language
Choose two.Examine this list of MySQL data directory binary
logs:binlog.000001binlog.000002.......binlog.000289binlog.000300binlog.000301
binlog.indexNow
examine this command, which executes successfully:mysqldump --delete-master-logs --all
databases > /backup/db_backup.sqlWhich two are true?
E) All databases, excluding master metadata, are backed up to the output file. [错误]
C) All binary logs are backed up and then deleted. [错误]
A) All databases are backed up to the output file. [正确]
D) All binary logs are deleted from the master. [错误]
F) All details regarding deleted logs and master metadata are captured in the output file. [错误]
B) All non-active binary logs are removed from the master. [正确]
解析
本题考查mysqldump参数
-delete-master-logs:
在备份完成后,删除不再需要的二进制日志
但会保留当前正在使用的二进制日志(binlog.000301)
因此选项B是正确的(删除的是非活跃日志)
选项D说"所有"二进制日志被删除是错误的
language
E) All databases, excluding master metadata, are backed up to the output file. [错误]
错误。--all-databases会备份所有数据库,包括主元数据。
C) All binary logs are backed up and then deleted. [错误]
错误。mysqldump不会备份二进制日志本身,它只备份数据库内容。
A) All databases are backed up to the output file. [正确]
所有数据库都被备份到输出文件。
D) All binary logs are deleted from the master. [错误]
F) All details regarding deleted logs and master metadata are captured in the output file. [错误]
错误。输出文件只包含数据库的SQL转储,不包含日志删除的详细信息。
B) All non-active binary logs are removed from the master. [正确]
试题35:
language
You want to install and configure MySQL on Linux server with tarball binaries in the
/app/mysq1/directory, where the bin directory is found at 1 app/mysql/bin and the data directory at /app/data.
Which two parameters are required to configure the MySQL instance?
E)The configuration innodb_log_group home dir=/datadir is needed. [错误]
A)The configuration basedir=/app/mysql is needed. [错误]
C)The configuration log-bin=/app/data is needed. [错误]
D)The configuration datadir=/ app/mysql/data is needed [正确]
F)The configuration basedir=/app/mysql/bin is needed. [错误]
B)The configuration datadir=/app/data is needed. [正确]
解析
language
题目说
安装目录在/app/mysql/
binlog日志目录在/app/mysql/bin
data目录在/app/data
E) innodb_log_group_home_dir=/datadir:
InnoDB日志组配置
不是安装必须的参数
A) basedir=/app/mysql:
虽然basedir是重要参数
但MySQL通常能自动识别basedir
不是"必须"配置的参数
C) log-bin=/app/data:
二进制日志位置配置
不是安装必须的参数
D) datadir=/app/mysql/data:
虽然题目指定的数据目录是/app/data
但MySQL默认会尝试在basedir下的data目录查找
这也是一个常见的配置位置
F) basedir=/app/mysql/bin:
basedir应指向MySQL安装根目录
不应指向bin子目录
B) datadir=/app/data:
这是题目明确指定的数据目录位置
datadir参数是MySQL必须配置的核心参数
指定了MySQL数据库文件的存储位置
试题36:
language
A valid raw backup of the shop.customers MyISAM table was taken.You must restore the table.You begin with these steps:
1. Confirm that secure_file_priv=' /var/tmp'
2. mysql>DROP TABLE shop.customers;
3. shell> cp /backup/ customers.MY* /var/ lib/mysql/shop/
Which two actions are required to complete the restore? (Choose two.)
F)mysql> IMPORT TABLE FROM /var/lib/mysql/shop/customers. Sdi [错误]
D)mysql> IMPORT TABLE FROM /var/ tmp/ customers.sdi [正确]
C)mysql>SOURCE ' /var/ tmp/ customers. sdi ' [错误]
G)mysql>ALTER TABLE shop. customers IMPORT TABLESPACE [错误]
A)shell> cp /backup/ customers.sdi /var/ tmp [正确]
B)shell>cp /backup/ customers.sdi /var/lib/ mysql/ shop/ [错误]
E)shell> cp /backup/ customers. frm /var/ lib/mysql/ shop/ [错误]
H)mysql> ALTER TABLE shop. customers DISCARD TABLES PACE [错误]
解析
language
需要恢复MyISAM表的原始备份,已执行步骤:
确认secure_file_priv='/var/tmp'
删除原表
复制.MY*数据文件到数据目录
具体的一个步骤如下:
shell> mkdir -p /var/lib/mysql/shop/
shell> chown -R mysql:mysql /var/lib/mysql/shop/
shell> cp /backup/customers.MY* /var/lib/mysql/shop/
shell> cp /backup/customers.sdi /var/tmp/
mysql> IMPORT TABLE FROM '/var/tmp/customers.sdi';
mysql> SELECT COUNT(*) FROM shop.customers;
权限问题:确保 /var/lib/mysql/shop/ 和 /var/tmp/ 的属主是 mysql 用户。
版本兼容性:MySQL 8.0+ 使用 .sdi,5.7 及以下版本需使用 .frm + FLUSH TABLES。
安全限制:secure_file_priv 必须正确配置,否则 IMPORT TABLE 会失败。
F)mysql> IMPORT TABLE FROM /var/lib/mysql/shop/customers.Sdi [错误]
错误:路径指向错误位置(应是/var/tmp)
D)mysql> IMPORT TABLE FROM /var/tmp/customers.sdi [正确]
C)mysql>SOURCE '/var/tmp/customers.sdi ' [错误]
错误:SOURCE命令用于执行SQL脚本,不能用于.sdi文件
G)mysql>ALTER TABLE shop. customers IMPORT TABLESPACE [错误]
错误:IMPORT TABLESPACE/DISCARD TABLESPACE用于InnoDB,不适用MyISAM
A)shell> cp /backup/customers.sdi /var/tmp [正确]
B)shell>cp /backup/customers.sdi /var/lib/mysql/shop/ [错误]
错误:.sdi文件不应直接复制到数据目录
E)shell> cp /backup/customers.frm /var/lib/mysql/shop/ [错误]
错误:MyISAM没有.frm文件(MySQL 8.0+)
H)mysql> ALTER TABLE shop. customers DISCARD TABLESPACE [错误]
错误:IMPORT TABLESPACE/DISCARD TABLESPACE用于InnoDB,不适用MyISAM
试题37:
language
Choose two.You are investigating performance problems in a MySQL database; all data fits in memory. You determine that SELECT queries to one table is the main cause for poor response times.
Which two have the biggest potential for eliminating the problem?
A)high concurrency [正确]
C)column definitions [错误]
B)operating system resources [错误]
D)innodb mutexes [错误]
E)non-transaction storage engine [正确]
F)table indexes [错误]
解析
一个 MySQL 数据库的性能问题,所有数据都能装入内存。你发现对某张表的 SELECT 查询是响应时间慢的主要原因。哪两个因素最有可能解决该问题?
language
B) 操作系统资源(operating system resources)
原因:题目已说明 数据完全在内存中,因此磁盘 I/O、CPU 或内存不足不太可能是瓶颈。
C) 列定义(column definitions)
原因:列的数据类型(如 VARCHAR vs INT)对内存查询性能影响较小,除非存在 不合理的大字段(如 TEXT)。
D) InnoDB 互斥锁(innodb mutexes)
原因:InnoDB 的 mutex 竞争通常在 高并发写入 时成为瓶颈,而题目聚焦于 SELECT 查询。
F) 表索引(table indexes)
原因:
如果查询已正确使用索引,进一步优化索引收益有限。
题目未提到索引缺失或慢查询,且数据在内存中,索引本身不是主要瓶颈。
A) 高并发(high concurrency)
影响:
高并发查询可能导致 锁竞争(如 InnoDB 行锁、表锁)。
即使数据在内存中,并发查询仍可能因 锁等待 或 线程调度 导致延迟。
E) 非事务型存储引擎(non-transaction storage engine)
影响:
InnoDB(事务型引擎)的 MVCC(多版本并发控制) 和 事务隔离 会带来额外开销。
如果业务不需要事务,改用 MyISAM 或 MEMORY 引擎可提升纯 SELECT 性能。
试题38:
language
Choose two.You have semi-synchronous replication configured and working with one slave.
rpl_semi_sync_master_timeout has never been reached.You find that the disk system on the master
has failed and as a result, the data on the master is completely unrecoverable.Which two statements
are true?
F)As soon as the incident happens, application can read data from the slave and rely on it to return
a full and current set of data. [错误]
D)Reads from the slave can return outdated data for some time, until it applies all transactions from
its relay log. [正确]
C)No committed transactions are lost. [正确]
B)Reads from the slave can return outdated data until the value of the
rpl_semi_sync_master_timeout variable is reached. [错误]
E)A small amount of committed transactions may be lost in case they were committed just before
the disk failure. [错误]
A)The slave automatically identifies that the master is unreachable and performs any required
actions so that applications can start using the slave as the new master. [错误]
解析
您已配置并成功运行半同步复制,并有一个从属服务器。rpl_semi_sync_master_timeout从未达到。您发现主服务器的磁盘系统出现故障,结果导致主服务器上的数据完全不可恢复。哪两个陈述是真实的?
问题背景
配置了半同步复制(semi-synchronous replication),且主库磁盘完全损坏,数据无法恢复。
rpl_semi_sync_master_timeout 从未触发 → 说明从库一直能正常确认接收事务。
需要判断哪些描述是正确的。
language
F)As soon as the incident happens, application can read data from the slave and rely on it to return a full and current set of data. [错误]
故障发生后应用可立即从从库读取最新数据
从库需先应用完 relay log 才能提供最新数据(如选项 D 所述)。
D)Reads from the slave can return outdated data for some time, until it applies all transactions from its relay log. [正确]
从库的读取可能会暂时返回过时数据
原因:
从库的 SQL 线程应用 relay log 可能存在延迟(即使已接收事务日志)。
在完全应用所有 relay log 前,查询可能读到稍旧的数据。
C)No committed transactions are lost. [正确]
半同步复制的核心保证:
主库提交事务前,至少一个从库已接收该事务的日志(但可能未完全执行)。
由于 rpl_semi_sync_master_timeout 未触发,说明从库始终正常响应,所有已提交的事务都已传输到从库。
结论:即使主库数据丢失,从库仍保有完整事务日志,无数据丢失。
B)Reads from the slave can return outdated data until the value of the
rpl_semi_sync_master_timeout variable is reached. [错误]
从库返回过时数据直到 rpl_semi_sync_master_timeout 触发
timeout 仅影响主库是否降级为异步复制,与从库数据一致性无关。
E)A small amount of committed transactions may be lost in case they were committed just before
the disk failure. [错误]
少量已提交事务可能丢失
半同步复制已确保事务传输到从库,题目明确 timeout 未触发,故无丢失。
A)The slave automatically identifies that the master is unreachable and performs any required actions so that applications can start using the slave as the new master. [错误]
从属设备会自动识别主设备无法访问,并执行任何必要的操作,使得应用程序可以开始将从属设备用作新的主设备。
从库会自动检测主库不可用并接管
半同步复制不提供自动故障转移!需手动执行 CHANGE MASTER TO 或借助工具(如 MHA、Orchestrator)。
试题39:
language
Choose three.You are considering using file-system snapshots to back up MySQL. Which three statements are true?
B)The backup window is almost zero from the perspective of the application. [正确]
C)They allow direct copying of table rows with operating system copy commands. [错误]
F)They work best for transaction storage engines that can perform their own recovery when restored. [正确]
A)There is a slight performance cost while the snapshot is active. [正确]
G)They do not use additional disk space. [错误]
E)They take roughly twice as long as logical backups. [错误]
D)They do not back up views, stored procedures, or configuration files. [错误]
解析
文件系统快照(file-system snapshots)来备份 MySQL。哪三个描述是正确的?
language
A) 快照激活期间会有轻微的性能开销
原因:
文件系统快照(如 LVM、ZFS)需要维护元数据和数据块映射,可能对 I/O 性能产生轻微影响。
但对应用透明,通常影响较小。
B) 备份窗口几乎为零(应用无感知)
原因:
快照是瞬时完成的,无需长时间锁定数据库或停止服务。
应用仍可正常读写,仅快照创建瞬间可能有短暂延迟。
F) 最适合事务型存储引擎(如InnoDB)
原因:
事务型引擎(InnoDB)通过redo log和undo log确保数据一致性。
快照恢复后,InnoDB 可自动回放日志修复数据,而 MyISAM 等非事务引擎可能损坏。。
C) 允许通过操作系统命令直接复制表数据行
问题:
快照备份的是文件块(如 .ibd 文件),而非单表数据行。
直接复制文件需配合数据库一致性措施(如锁表或停服务)。
D) 不备份视图、存储过程或配置文件
问题:
文件系统快照会备份所有文件,包括 mysql 系统库(存储视图、存储过程)和 my.cnf。
但需确保快照包含完整 MySQL 数据目录。
E) 耗时约为逻辑备份的两倍
问题:
快照是物理备份,速度远快于逻辑备份(如 mysqldump)。
逻辑备份需逐行导出 SQL 语句,而快照是块级复制。
G) 不占用额外磁盘空间
问题:
快照需要预留空间存储变更数据(如 LVM 快照的 COW 机制)。
若原数据修改频繁,快照空间可能快速增长。
试题40:
language
Choose two.Which two commands will display indexes on the parts table in the manufacturing
schema?
B)SELECT * FROM information_schema.statistics WHERE table_schema= 'manufacturing' AND
TABLE_NAME= 'parts' ; [错误]
D)SHOW INDEXES FROM manufacturing.parts; [正确]
['description', 'EXPLAIN']
C)DESCRIBE manufacturing.parts; [正确]
E)SELECT * FROM information_schema.COLUMN_STATISTICS; [错误]
解析
language
查看索引的标准方法:
SHOW INDEXES FROM 表名;(最完整)
DESCRIBE 表名;(快速查看主键和索引列)
其他注意事项:
EXPLAIN 用于分析查询执行计划,不直接显示索引定义。
information_schema.STATISTICS 需注意表名大小写(MySQL 8.0+ 区分大小写)。