MySQL 8.0 OCP 1Z0-908 121-130题
Q121.Examine these statements and output:
mysql> GRANT PROXY ON accounting@localhost TO ’ ‘@ ‘%’;
mysql> SELECT USER(), CURRENT_USER(), @@proxy_user;
±-----------------------±------------------±----------------+
|USER() | CURRENT_USER() | @@proxy_user I
| jrsmith@localhost |accounting@localhost | ’ ‘@’%’ |
±-----------------------±------------------±----------------+
Which statement is true?
A)The user failed to define a username and the connecting username defaulted to ‘’@‘%’.
B)The user is authorized as the jrsmith@localhost user.
C)The user is authenticated as the anonymous proxy user ’ '@ ‘%’.
D)The user is logged in with --user=accounting as an option.
E)The user is authorized as the accounting@localhost user.
Answer:E
select user()查询当前登录得用户,比如jrsmith@localhost,就说明jrsmith是在本机登录得
select current_user(),该函数查询得是mysql.user表中,该用户的信息,比如在mysql.user表中,这个用户是accounting@localhost
示例:远程登录到MySQL服务器
mysql> select user(),current_user();
+---------------------+----------------+
| user() | current_user() |
+---------------------+----------------+
| manager@10.2.18.172 | manager@% |
+---------------------+----------------+
1 row in set (0.00 sec)
输出中得10.2.18.172,就是登录的客户端的IP,manager是登录用户,current_user是权限表中的用户
代理用户是 ' '@'%',但实际登录用户是 jsmith@localhost,并且通过代理机制被授权为 accounting@localhost选项A:连接到该数据库的用户是jrsmith@'localhost',故该选项错误
选项B:授权表中的是accounting@localhost,而不是jrsmith@localhost
选项C:curren_user()显示该用户被授权为accounting@localhost
选项D:登录用户是jrsmith@localhost,所以使用的不是--user=accounting选项
选项E:授权表中是accounting@localhost,所以正确
Q122.Which two actions can obtain information about deadlocks?
A)Run the SHOW ENGINE INNODB MUTEX command from the mysql client.
B)Enable the innodb_status_output_locks global parameter.
C)Enable the innodb_print_all_deadlocks global parameter.
D)Run the SHOW ENGINE INNODB STATUS command from the mysql client.
E)Use the sys.innodb_lock_waits view.
Answer:CD
选项A:SHOW ENGINE INNODB MUTEX输出InnoDB mutex和rw-lock的统计信息.
选项B:innodb_status_output_locks参数开启,可以监控锁信息,输出的信息比show engine innodb status中输出的锁信息更详细一些,但是不是关于死锁的
选项C:innodb_print_all_deadlocks,开启该参数,用户十五的思索信息将会被记录在error log中
选项D:show engine innodb status也会输出死锁信息,不过语句可能打印不全
选项E:innodb_lock_waits视图可以查询锁等待的信息
注意:题目重要的是死锁信息
Q123.Examine this statement, which executes successfully:
CREATE TABLE world.city(
ID int NOT NULL AUTO_INCREMENT ,
Name char(35) NOT NULL DEFAULT ‘’ ,
CountryCode char(35) NOT NULL DEFAULT ’ ',
District char (20) NOT NULL DEFAULT ‘’,
Population int NOT NULL DEFAULT ‘0’,
PRIMARY KEY (ID) ,
KEY CountryCode (CountryCode)
)ENGINE=InnoDB;
You want to improve the performance of this query:
SELECT Name
FROM world. city
WHERE Population BETWEEN 1000000 AND 2000000;
Which change enables the query to succeed while accessing fewer rows?
A)ALTER TABLE world.city ADD INDEX (Name) ;
B)ALTER TABLE world.city ADD SPATIAL INDEX (Name) ;
C)ALTER TABLE world.city ADD FULLTEXT INDEX (Name) ;
D)ALTER TABLE world.city ADD FULITEXT INDEX (Population);
E)ALTER TABLE world.city ADD SPATIAL INDEX (Population) ;
F)ALTER TABLE world.city ADD INDEX (Population) ;
Answer:F
选项ABC,跟本次查询没有关系,并且population为int类型,所以就普通的二级索引就可以,没必要使用空间索引和全文索引
Q124.User ‘fwuser’@‘1ocalhost’ is registered with the MySQL Enterprise Firewall and has been granted
privileges for the SAKILA database.
Examine these commands that you executed and the results:
mysql> SELECT MODE FROM INFORMATION SCHENA.MYSOL_FIREKALL _USERS
WHERE USERHOST.fwuser@localhost’;
+-----------+
| MODE |
+-----------+
|PROTECTING |
+-----------+
INFORMATION SCHENA.MYSOL_FIREKALL _USERS字段
参考:https://dev.mysql.com/doc/refman/8.0/en/information-schema-mysql-firewall-users-table.html
USERHOST:用户的配置文件,每个用户的格式为username@'hostname'
MODE:OFF模式:此模式会禁用配置文件。防火墙会将其视为无效并忽略它。RECORDING模式:这是防火墙的训练模式。从匹配该配置文件的客户端接收到的传入语句,被视为对该配置文件可接受的语句,并成为其“指纹”的一部分。防火墙会记录每条语句的规范化摘要形式,以学习该配置文件的可接受语句模式。每个模式都是一条规则,而这些规则的联合就是配置文件的允许列表。需要注意的是,组配置文件与账户配置文件之间的一个区别在于,组配置文件的语句记录可以限制为仅来自单个组成员(训练成员)的语句。PROTECTING模式:在此模式下,配置文件会允许或阻止语句执行。防火墙会将传入语句与配置文件的允许列表进行匹配,仅接受匹配的语句,拒绝那些不匹配的语句。在RECORDING模式下训练完配置文件后,将其切换到PROTECTING模式,以增强MySQL对偏离允许列表的语句访问的防护。如果启用了mysql_firewall_trace系统变量,防火墙还会将被拒绝的语句写入错误日志。DETECTING模式:此模式会检测但不会阻止入侵(因为与配置文件的允许列表中的内容都不匹配而被认为是可疑的语句)。在DETECTING模式下,防火墙会将可疑语句写入错误日志,但会接受它们,不会拒绝访问。
mysql> SELECT RULE FROM INFORMATION SCHENA.MYSQL_FIREWALL_WHITELIST WHERE USRHOST * ‘fwuser@localhost’;
±----------------------------------------------------------------------------------+
|RULE |
±----------------------------------------------------------------------------------+
|SELECT ‘first_Name’ n,‘last._name’ FROM .’ customer’ WHERE ‘customer_id’ ? |
|SELECT 'get. customer_balance’ (? . NOW ( ) ) |
|UPDATE ‘rental’ SET ‘return date’. = NOwl ( ) WHERE ‘rental_id’ = ? |
|SELECT @@‘version comment’ LIMIT ? |
±----------------------------------------------------------------------------------+
You then execute this command:
mysql> CALL mysql.sp_set_firewall_mode(‘fwuser@localhost’,‘RESET’);
Which two are true?
A)The fwuser@localhost account is removed from the mysql.user table.
B)The information_schema.MYSQL_FIREWALL_WHITELIST table is truncated,
C)The whitelist of the fwuser@localhost account is truncated.
D)The mysql.Firewall_users table is truncated.
E)The firewall resets all options to default values.
F)The fwusere@localhost account mode is set to DETECTING.
G)The fwuserd@localhost account mode is set to OFF.
Answer:CG
mysql.sp_set_firewall_mode函数用来设置防火墙的规则
CALL mysql.sp_set_firewall_group_mode(group, 'RESET');RESET会导致删掉"该用户的"所有防火墙规则,"并且关闭防火墙"选项A:这个不会影响mysql.user表
选项B:只是删除了关于fwuser@localhost的信息,而不是truncate MYSQL_FIREWALL_WHITELIST这个整张表
选项C:用户fwuser@localhost的白名单被truncate,这个是正确的
选项D:Firewall_users用户表不受影响,该表存储的是防火墙用户的配置信息
选项E:参考上面解释
选项F:参考上面解释
Q125.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:
[mysqld]
datadir=/data1/
innodb_buffer_pool_size=28G
innodb_log_file_size=150M
Which four changes provide the most performance improvement, without sacrificing data integrity?
A)innodb-doublewrite=off
B)innodb_1og_group_home_dir=/data2/
C)innodb_1og_file_size=1G
D)innodb_undo_directory=/dev/shm
E)log-bin=/data2/
F)innodb_flush_log_at_trx_commit=0
G)sync_binlog=0
H)innodb_buffer_pool_size=32G
I)disable-log-bin
Answer:BCGH
选项A:关闭doublewrite,有可能导致数据损坏
选项B:innodb_1og_group_home_dir是redo日志的路径,修改该路径,可以分散一些磁盘读写压力
选项C:innodb_1og_file_size定义了redo文件大小,增大该文件,就可以避免频繁切换文件,也可以存储更多的redo,而不会在业务比较大的情况下,写redo无法写入而造成的等待
选项D:innodb_undo_directory定义了undo表空间的路径,而/dev/shm在是在内存里,而不在磁盘上,所以该答案错误
选项E:log_bin参数指定binlog的路径,将其改到/data2中也可以分散磁盘的IO压力
选项F:该参数控制 redo log buffer 里的数据刷入磁盘文件的策略,修改为0的话,那就依靠 InnoDB 的主线程每秒执行一次刷新到磁盘。此时可能你提交事务了,结果 mysql 宕机了,然后此时内存里的数据全部丢失。
选项G:sync_binlog=0,将binlog写入磁盘缓存,但不刷盘(fsync),系统宕机可能会丢数据,但是可以通过redo,undo回滚前滚达到最终的数据一致性
选项H:数据只有28G,上下波动,最多也就波动3G,对性能影响不大
选项I:禁用binlog,可以提升性能,但是会牺牲数据完整性
Q126.You have a MySQL instance with GTIDs enabled. This instance runs more than 100 transactions per second.
You discover that some data was deleted at a particular point in time.
You decide to perform a recovery from the binary logs as they are all available.
Which two commands can restore the database to the point right before data was deleted?
A) mysqlbinlog --skip-gtids…
B) mysqlbinlog --stop-position…
C) START SLAVE SQL_THREAD UNTIL SQL_BEFORE_GTIDS=…
D) mysqlbinlog --stop-datetime…
E) START SLAVE IO_THREAD UNTIL SQL_BEFORE_GTIDS=… …
Answer:AC
选项A: 不正确。跳过GTID处理无法确保恢复到删除操作之前。
选项B:通过指定停止位置,可以将数据库恢复到指定位置之前的状态,适用于基于位置的恢复。
选项:D:特定的时间点,使用stop-datetime时间精度可能不够,因为该系统可以每秒运行100个事务
指定停止回放的日期时间。恢复操作会执行到指定时间点为止,因为这个时间点格式为(YYYY-MM-DD hh:mi:si)
选项C,E,由于SQL线程是进行事务回放的,所以是选C
个人认为选BC
Q127.You need to find the number of examined rows for queries that have completed.
All relevant configurations are enabled for recording the information.
Which three sources contain the number of examined rows?
A. the Performance Schema
B. the Information Schema
C. the error log
D. the general query log
E. the sys schema
F. the slow query log
Answer:AEF
选项A:提供了详细的性能指标和运行时信息,包括查询检查的行数。可以通过查询 performance_schema.events_statements_current 或其他相关表来获取已完成查询的行数信息。
选项B:没有
选项C:只记录数据库运行的错误西南西
选项D:只记录数据库连接和执行的语句
选项E:是一个高级的性能监控工具,它提供了更易于使用的视图来查看服务器的性能指标,包括查询检查的行数
选项F:慢查询日志记录了执行时间超过设定阈值的查询,包含了查询的详细信息,包括检查的行数
Q128.Identify two ways to significantly improve data security.
A)Configure mysqld to run as the system admin account, such as root.
B)Use a private network behind a firewall.
C)Configure mysqld to use only networked disks.
D)Configure MySQL to have only one administrative account.
E)Configure mysqld to use only local disks or attached disks and to have its own account in the host system.
Answer:BD
选项A:使用root安全性更低
选项B:使用防火墙后的私有网络,这个会提高数据安全性
选项C:将mysqld配置在网络磁盘上,这个风险性更大了
选项D:只配置一个管理员账户,这个正确
选项E:
Q129.Which characters are most commonly used in a SQL injection attack?
A)
B) null (\0) and newline (\n)
C) ^ and $
D) + and -
E) 'and"
Answer:E
SQL注入不懂
Q130.Examine these commands, which execute successfully on the ic1 host:
mysqlsh> dba. createCluster(‘cluster1’, {}memberWeight:35})
mysqlsh> var mycluster = dba.getCluster ()
mysqlsh> mycluster.addInstance(’ ic@ic2’, {memberWeight:25})
mysqlsh> mycluster.addInstance(’ ic@ic3’, {memberWeight:50})
Now examine this configuration setting, which is the same on all nodes:
group_replication_consistency=BEFORE_ON_PRIMARY_FAILOVER
Which statement is true if primary node ic1 fails?
A)Node ic2 becomes the new primary and existing transactions are considered stale and rolled back.
B)Node ic3 becomes the new primary and existing transactions are considered stale and rolled back.
C)Node ic3 becomes the new primary and is ignored until any backlog of transactions is completed//节点 ic3 成为新的主节点,并在完成所有积压的事务之前被忽略
D)Only two nodes remain so the election process is uncertain and must be done manually.
E)Node ic2 becomes the new primary and is ignored until any backlog of transactions is completed.
Answer:C
group_replication_consistency
因为ic3的权重较高,所以如果ic1挂了那么ic3就会被选主,并且等待原来的事务回放完成后,在正式对外提供服务
EFORE_ON_PRIMARY_FAILOVER:在发生切换时,连到新主的事务会被阻塞,等待先序提交的事务回放完成;这样确保在故障切换时客户端都能读取到主服务器上的最新数据,保证了一致性