目錄
- 第11題
- 題目分析
- 正確答案
- 第12題
- 題目分析
- 正確答案
- 第13題
- 題目分析
- 正確答案
- 第14題
- 題目分析
- 正確答案
- 第15題
- 題目分析
- 正確答案
- 第16題
- 題目分析
- 正確答案
- 第17題
- 題目分析
- 正確答案:
- 第18題
- 題目分析
- 正確答案
- 第19題
- 題目分析
- 正確答案
- 第20題
- 題目分析
- 正確答案
第11題
Which four are types of information stored in the MySQL data dictionary? (Choose four.)
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 會存儲在數據字典中。包括參數、返回值類型、定義語句等。
正確答案
B) table definitions
C) access control lists
D) view definitions
G) stored procedure definitions
第12題
Choose two.Examine this SQL statement
mysql> GRANT r_read@localhost TO mark WITH ADMIN OPTION;
Which two are true?
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
的行為,重點是理解角色授權及其“管理選項”的影響。
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錯誤。
正確答案
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?
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
的新表:
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:
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
只能對應一個數據文件,不能多個。
正確答案
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?
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),用于提高可用性和負載均衡。
正確答案
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?
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
格式:
[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 標準憑據存儲路徑 | ?錯誤 |
正確答案
B) /etc/my.cnf
D) $HOME/.my.cnf
E) $HOME/.mylogin.cnf
第16題
choose two.Examine the modified output:
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?
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
,說明主從之間數據流正常。
正確答案
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?
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
),但它們主要記錄的是 數據更改事件,而非“僅僅是”管理命令。
正確答案:
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?
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 的命令:
mysqladmin -u root -p shutdown
它通過客戶端與MySQL
服務通信,請求有序關機。
systemctl stop mysqld
:? 正確。
在 Oracle Linux 7(使用 systemd)中,這是一種推薦方式:
sudo systemctl stop mysqld
會優雅地停止服務,執行與 mysqladmin shutdown
類似的行為。
mysql> SHUTDOWN;
? 正確。
如果你已經連接到了mysql
客戶端,并擁有SHUTDOWN
權限,可以直接執行:
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
這個選項。
正確答案
? C) mysqladmin shutdown
? F) systemctl stop mysqld
? G) mysql> SHUTDOWN;
第19題
Choose two.Examine this MySQL Shell command:
dba.rebootClusterFromCompleteOutage ()
Which two statements are true?
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) 啟停所有實例:命令不主動停止實例,而是基于已停止的集群進行恢復。
正確答案
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?
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)必須嚴格保密,不應該讓組或其他用戶有讀取權限。當前權限允許組用戶讀取,存在安全風險。修改為僅用戶可讀寫是必要的,這是關鍵的安全措施。
正確答案
A)Remove the world read/execute privilege from the accounting directory.
F)Remove group read/write privileges from the private key.pem file.