MySQL 8.0 OCP 英文题库解析(一)
Oracle 为庆祝 MySQL 30 周年,从 2025.04.20 ~ 2025.07.31 之间,所有人均可以免费考取 MySQL OCP 认证。从今天开始,将英文题库免费公布出来,并进行解析,帮助大家在一个月之内轻松通过OCP认证,省1700多RMB,这个羊毛薅定了。
试题1:
Choose two.Your MySQL server was upgraded from an earlier major version.The sales database contains three tables, one of which is the transactions table, which has 4 million rows.You are running low on disk space on the datadir partition and begin to investigate. Examine these commands and output:Which two statements are true?
C)Executing SET GLOBAL innodb_row_format=COMPRESSED and then ALTER TABLE transactions will free up disk space. [错误]
B)Truncating the sales and leads table will free up disk space. [正确]
A)The transactions table was created with innodb_file_per_table=OFF. [正确]
D)Executing ALTER TABLE transactions will enable you to free up disk space. [错误]
E)Truncating the transactions table will free up the most disk space. [错误]
解析
这个题目的意思是,您的 MySQL 服务器是从早期的主要版本升级而来的。sales 数据库包含三个表,其中一个是 transactions 表,该表有 400 万行。您的 datadir 分区上的磁盘空间不足,如何处理。检查这些命令和输出:哪两个陈述是正确的?
选项C:
Executing SET GLOBAL innodb_row_format=COMPRESSED and then ALTER TABLE transactions will free up disk space.
虽然这可以压缩表,但题目中可知,transactions 表并没有独立出来(从ls -l sales中得出)该表在系统表空间中,ALTER操作不会释放空间给操作系统。因此该选项错误。
选项D:
Executing ALTER TABLE transactions will enable you to free up disk space.
对于系统表空间中的表,ALTER操作不会释放空间给操作系统。因此该选项错误。
选项E:
Truncating the transactions table will free up the most disk space
执行Truncate释放空间,但这些空间仍保留在系统表空间内,不会返还给操作系统,因此也是错误选项。
选项A:
The transactions table was created with innodb_file_per_table=OFF.
从图片中得知如果设置了独立表空间,在ls -l sales 的时候,应该可以看到三个表,但是这里只显示有2个表,transactions 并不在其中,可以得知,这个表建立的时候,还没有设置独立表空间,因此正确。
选项B:
Truncating the sales and leads table will free up disk space.
trunacate 操作有独立表空间的表,能释放表空间,该选项正确。
试题2:
[‘title’, ‘EXPLAIN’]
B)35 rows from the city table are included in the result. [错误]
E)The query returns exactly 125 rows. [正确]
C)The optimizer estimates that 51 rows in the country table have Continent = ’ Asia '. [错误]
D)It takes more than 8 milliseconds to sort the rows. [错误]
A)The country table is accessed as the first table, and then joined to the city table. [正确]
解析
从题目可以看出,这是一个执行计划。
选项B:
35 rows from the city table are included in the result.
结果中包含 city 表中的 35 行,这是错误的,从倒数第二行可以看到filter中,经过过滤后,只有2行了。
选项E:
The query returns exactly 125 rows.
从最上面一行,显示的是最终运行结果,可以看到rows=125,因此该选项正确。
选项C:
The optimizer estimates that 51 rows in the country table have Continent = ’ Asia '.
优化器估计 country 表中的 51 行具有 Continent = ’ Asia '。从倒数第4行得知,预估是34行,实际返回51行,因此该选项错误。
选项D:
It takes more than 8 milliseconds to sort the rows.
从第一行得知,总花费时间是8秒多,并不是指排序花费8秒。
选项A:
The country table is accessed as the first table, and then joined to the city table.
country 表作为第一个表进行访问,然后联接到 city 表。从执行计划的原理得知,符合。
试题3:
Choose four.A newly deployed replication master database has a 10/90 read to write ratio. The complete dataset is currently 28G but will never fluctuate beyond ±10%.The database storage system consists of two locally attached PCI- E Enterprise grade disks (mounted as /data1 and /data2)The server is dedicated to this MySQL Instance. System memory capacity is 64G.The my.cnf file contents are displayed here:mysqlddatadir=/data1/ innodb_buffer_pool_size=28G
innodb_log_file_size=150M Which four changes provide the most performance improvement, without sacrificing data integrity?
B)innodb_log_group_home_dir=/data2/ [正确]
H)innodb_buffer_pool_size=32G [正确]
A)innodb-doublewrite=off [错误]
F)innodb_flush_log_at_trx_commit=0 [错误]
D)innodb_undo_directory=/dev/shm [错误]
C)innodb_log_file_size=1G [正确]
G)sync_binlog=0 [错误]
E)log-bin=/data2/ [正确]
I)disable-log-bin [错误]
解析:
题目意思是,新部署的数据库集群,主库的读写比为 10/90。完整的数据集目前为 28G,但波动永远不会超过 -10%。数据库存储系统由两个本地连接的 PCI-E 企业级磁盘(挂载为 /data1 和 /data2)组成服务器专用于此 MySQL 实例。系统内存容量为 64G。my.cnf 文件内容显示:mysqlddatadir=/data1/
innodb_buffer_pool_size=28G
innodb_log_file_size=150M
哪四个变化在不牺牲数据完整性的情况下提供了最大的性能提升?
根据题目描述的场景(主库、读写比例10/90、64G内存、双磁盘系统)
选项B:
innodb_log_group_home_dir=/data2/ [正确]
原因:将InnoDB重做日志文件放到第二个磁盘(/data2)上,可以与数据文件(/data1)实现I/O分离
优势:减少磁盘争用,提高写入性能,不影响数据完整性
选项H:
innodb_buffer_pool_size=32G [正确]
原因:当前设置为28G,而服务器有64G内存,数据集大小28G±10%
优势:增大缓冲池可以缓存更多数据,减少磁盘I/O,特别适合读少写多的场景(10/90)
选项C:
innodb_log_file_size=1G [正确]
原因:当前150M的日志文件对于28G数据集来说太小
优势:增大日志文件可以减少检查点频率,降低I/O压力,提高写入性能
选项E:
log-bin=/data2/ [正确]
原因:将二进制日志放到第二个磁盘上,与数据文件和重做日志分离
优势:减少主库的I/O争用,提高复制性能,不影响数据安全
选项A:
innodb-doublewrite=off [错误]
风险:关闭双写缓冲会危及数据完整性,可能导致页面部分写入
选项F:
innodb_flush_log_at_trx_commit=0 [错误]
风险:设置为0可能在崩溃时丢失最多1秒的事务数据。设置成0时,事务提交的时候不会触发写日志文件的操作,日志缓存中的数据以每秒一次的频率写入到日志文件中。因此有风险。
选项D:
innodb_undo_directory=/dev/shm [错误]
风险:将undo日志放在内存文件系统,服务器重启会丢失数据
选项G:
sync_binlog=0 [错误]
风险:可能导致二进制日志不同步,主从数据不一致。设置成0时,事务提交的时候不会把二进制日志刷新到磁盘,刷磁盘的动作由操作系统控制。
选项I:
disable-log-bin [错误]
风险:禁用二进制日志会破坏复制功能
最佳的四项优化是:
将重做日志移到第二块磁盘
适当增大缓冲池至32G
增大InnoDB日志文件至1G
将二进制日志放在第二块磁盘
试题4:
Which two actions will secure a MySQL server from network-based attacks?
D)Change the listening port to 3307. [错误]
E)Allow connections from the application server only. [正确]
A)Use MySQL Router to proxy connections to the MySQL server. [错误]
B)Place the MySQL instance behind a firewall. [正确]
C)Use network file system (NFS) for storing data. [错误]
解析:
哪两项作将保护 MySQL 服务器免受基于网络的攻击?
D) 将监听端口改为 3307。[错误]
通过修改端口实现的安全只是"隐蔽安全"(security through obscurity),专业攻击者仍能通过端口扫描发现服务。
E) 仅允许来自应用程序服务器的连接。[正确]
A) 使用 MySQL Router 代理到 MySQL 服务器的连接。[错误]
虽然Router可以提供负载均衡和故障转移,但本身并不增强安全性
B) 将 MySQL 实例置于防火墙后面。[正确]
C) 使用网络文件系统 (NFS) 存储数据。[错误]
NFS会引入新的安全风险,如未加密的网络传输可能被窃听。
试题5:
Choose four.You must store connection parameters for connecting a Linux-based MySQL client to a remote Windows-based MySQL server listening on port 3309.Which four methods can be used to configure user, host, and database parameters?
D)Execute the mysqladmin command to configure the user connection. [错误]
C)Configure ~/.my.cnf. [正确]
H)Use the usermod program to store static user information. [错误]
G)Define a UNIX socket. [错误]
E)Execute the command in a bash script. [正确]
B)Execute mysql_config_editor to configure the user connection. [正确]
A)Embed login information into the SSH tunnel definition. [错误]
I)Configure ~/.ssh/config for public key authentication. [错误]
F)Configure environment variables. [正确]
解析:
您必须存储连接参数,以便将基于 Linux 的 MySQL 客户端连接到侦听端口 3309 的基于 Windows 的远程 MySQL 服务器。可以使用哪四种方法来配置用户、主机和数据库参数?
C) 配置 ~/.my.cnf [正确]
E) 在bash脚本中执行命令 [正确]
B) 使用MySQL提供的安全凭证存储工具mysql_config_editor配置用户连接 [正确]
F) 配置环境变量 [正确]
D) 执行mysqladmin命令配置用户连接 [错误]
原因:mysqladmin用于服务器管理,不能存储连接配置
H) 使用usermod程序存储静态用户信息 [错误]
原因:usermod用于系统用户管理,与MySQL无关
G) 定义UNIX socket [错误]
原因:UNIX socket仅适用于本地连接,不适用于远程Windows服务器
A) 将登录信息嵌入SSH隧道定义 [错误]
原因:SSH隧道配置不包含MySQL连接参数
I) 配置~/.ssh/config用于公钥认证 [错误]
原因:SSH配置与MySQL客户端连接参数无关
未完,待续。后续题库会陆续发出,请关注。