1. A simple master-to-slave replication is currently being used. The following information is extracted from the SHOW SLAVE STATUS output:
Last_SQL_Error: Error 'Duplicate entry '8' for key 'PRIMARY'' on query. Default database: 'mydb'.
Query: 'insert into mytable VALUES ('8', 'George')'
Skip_Counter: 0
Retrieved_Gtid_Set: 38f32e23480a7-32a1-c323f78067fd37821: 1-8
Auto_Position: 1
You execute a "SHOW CREATE TABLE mytable" on the slave:
CREATE TABLE 'mytable' (
'ID' int(11) NOT NULL DEFAULT '0',
'name' char(10) DEFAULT NULL,
PRIMARY KEY ('ID')
)
The table mytable on the slave contains the following:
You have issued a STOP SLAVE command. One or more statements are required before you can issue a START SLAVE command to resolve the duplicate key error.
Which statement should be used?
A. SET GLOBAL SQL_SKIP_SLAVE_COUNTER=1
B. SET GTID_NEXT="CONSISTENCY";
BEGIN;
COMMIT;
SET GTID_NEXT=" AUTOMATIC’;
C. SET GLOBAL enforce_gtid_consistency=ON
D. SET GTID_EXECUTED="38f32e23480a7-32a1-c323f78067fd37821 : 9";
E. SET GTID_NEXT="38f32e23480a7-32a1-c323f78067fd37821 : 9";
BEGIN;
COMMIT;
SET GTID_NEXT="AUTOMATIC";
分析:此题中使用的Replication是通过GTID实现的,因此A错,因此GLOBAL SQL_SKIP_SLAVE_COUNTER=1对使用GTID进行的Replication无效C错,因为GLOBAL enforce_gtid_consistency=ON是实现的前提。由于GTID_NEXT的有效值为:AUTOMATIC / ANONYMOUS /:因此 B错
由于Retrieved_Gtid_Set: 38f32e23480a7-32a1-c323f78067fd37821: 1-8
因此已经收到主库事务1-8,因此报错是从第9个事务重复记录导致的,很有可能slave上的第8行被人为录入了,导致同步问题。
D错,因为GTID_EXECUTED表示已经执行完成的事务。
为了临时绕过这个问题,使用注入空事务(BEGIN; COMMIT; ) 代替完成第9个事务.
完成后GTID_EXECUTED才会变为"38f32e23480a7-32a1-c323f78067fd37821 : 9"
这时候重新SET GTID_NEXT="AUTOMATIC"; 重启slave后,开始从第10个事务开始同步。
参考:Using GTIDs for Failover and Scaleout
2. Consider the following statement on a RANGE partitioned table:
ALTER TABLE orders DROP PARTITION p1, p3;
What is the outcome of executing the above statement?
A. Only the first partition (p1) will be dropped as only one can be dropped at any time.
B. All data in p1 and p3 partitions are removed, but the table definition remains unchanged.
C. A syntax error will result as you cannot specify more than one partition in the same statement.
D. All data in p1 and p3 partitions are removed and the table definition is changed.
DROP PARTITION can be used to drop one or more RANGE or LIST partitions. This statement cannot be used with HASH or KEY partitions; instead, use COALESCE PARTITION (see below). Any data that was stored in the dropped partitions named in the partition_names list is discarded. For example, given the table t1 defined previously, you can drop the partitions named p0 and p1 as shown here:
ALTER TABLE t1 DROP PARTITION p0, p1;
参考:ALTER TABLE Partition Operations
3. You inherit a legacy database system when the previous DBA, Bob, leaves the company. You are notified that users are getting the following error:
mysql> CALL film_in_stock (40, 2, @count);
ERROR 1449 (HY000): The user specified as a definer ('bob'@'localhost') does not exist
How would you identify all stored procedures that pose the same problem?
A. Execute SELECT * FROM mysql.routines WHERE DEFINER='bob@localhost';.
B. Execute SHOW ROUTINES WHERE DEFINER='bob@localhost'.
C. Execute SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE DEFINER='bob@localhost';.
D. Execute SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER='bob' and HOST='localhost';.
E. Examine the Mysql error log for other ERROR 1449 messages.
film_in_stock 是个存储过程,所以在 INFORMATION_SCHEMA.ROUTINES 中查看相关信息。
INFORMATION_SCHEMA.PROCESSLIST: provides information about which threads are running. 查看运行中的线程
INFORMATION_SCHEMA.ROUTINES: provides information about stored routines (both procedures and functions).
参考:
ROUTINES Table
PROCESSLIST Table
4. When designing an InnoDB table, identify an advantage of using the BIT datatype Instead of one of the integer datatypes.
A. BIT columns are written by InnoDB at the head of the row, meaning they are always the first to be retrieved.
B. Multiple BIT columns pack tightly into a row, using less space.
C. BIT(8) takes less space than eight TINYINT fields.
D. The BIT columns can be manipulated with the bitwise operators &, |, ~, ^, <<, and >>. The other integer types cannot.
答案:C
TINYINT = 1 byte
1 byte = 8 bit
显然 BIT(8) 占用空间小于 TINYINT(8)
参考:Data Type Storage Requirements
5. ROW-based replication has stopped working. You investigate the error log file and find the following entries:
2013-08-27 14:15:47 9056 [ERROR] Slave SQL: Could not execute Delete_rows event on table test.t1; Can’t find record in ‘t1’, Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event’s master log 56_master-bin.000003, end_log_pos 851, Error_code: 1032
2013-08-27 14:15:47 9056 [warning] Slave: Can’t find record in ‘t1’ Error_code: 1032
2013-08-27 14:15:47 9056 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with “SLAVE START”. We stopped at log ‘56_masterbin.000003’ position 684
Why did you receive this error?
A. The slave SQL thread does not have DELETE privileges to execute on test.t1 table.
B. The table definition on the slave litters from the master.
C. Multi-threaded replication slaves can have temporary errors occurring for cross database updates.
D. The slave SQL thread attempted to remove a row from the test.t1 table, but the row did not exist.
分析:
首先是 ROW-based replication,ERROR 提示中已经写明 Can't find record in 't1',很明显 slave 上的 t1 表中没有这条记录。
6. mysqldump was used to create a single schema backup;
Shell> mysqldump –u root –p sakila > sakila2013.sql
Which two commands will restore the sakila database without interfering with other running database?
A. Mysql> USE sakila;
LOAD DATA INFILE 'sakila2013.sql';
B. Shell> mysql –u root –p sakila < sakila2013.sql
C. Shell> mysqlimport –u root –p sakila sakila2013.sql
D. Shell> mysql –u root -p –e 'use sakila; source sakila2013.sql'
E. Shell> mysql –u root –p –silent < sakila2013.sql
A、C错:LOAD DATA INFILE 和 mysqlimport 对应的是 SELECT...INTO OUTFILE 导出的表数据文件,而 mysqldump 导出的文件包含的数据是以可执行sql语句
7. Consider the Mysql Enterprise Audit plugin.You are checking user accounts and attempt the following query:
Mysql> SELECT user, host, plugin FROM mysql.users;
ERROR 1146 (42S02): Table ‘mysql.users’ doesn’t exist
Which subset of event attributes would indicate this error in the audit.log file?
A. NAME=”Query”
STATUS=”1146”
SQLTEXT=”select user,host from users”/>
B. NAME=”Error”
STATUS=”1146”
SQLTEXT=”Error 1146 (42S02): Table ‘mysql.users’ doesn’t exist”/>
C. NAME=”Query”
STATUS=”1146”
SQLTEXT=” Error 1146 (42S02): Table ‘mysql.users’ doesn’t exist”/>
D. NAME=”Error”
STATUS=”1146”
SQLTEXT=”select user,host from users”/>
E. NAME=”Error”
STATUS=”0”
SQLTEXT=”Error 1146 (42S02): Table ‘mysql.users’ doesn’t exist”/>
NAME:
Audit When auditing starts, which may be server startup time
Connect When a client connects, also known as logging in
Query An SQL statement (executed directly)
Prepare Preparation of an SQL statement; usually followed by Execute
Execute Execution of an SQL statement; usually follows Prepare
Shutdown Server shutdown
Quit When a client disconnects
NoAudit Auditing has been turned off
B、D、E错,因为 NAME 参数中不包含 ERROR
SQLTEXT:A string representing the text of an SQL statement.
C错,因为 SQLTEXT 里存放的就是 SQL 表达式
8. Which query would you use to find connections that are in the same state for longer than 180 seconds?
A. SHOW FULL PROCESSLIST WHERE Time > 180;
B. SELECT * FROM INFORMATION_SCHEMA.EVENTS SHERE STARTS < (DATE_SUB(NOW(), INTERVAL 180 SECOND));
C. SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE STATE < (DATE_SUB(NOW(), INTERVAL 180 SECOND));
D. SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE TIME > 180;
A错,SHOW [FULL] PROCESSLIST 此语法后面不可以跟 where 语句
B错,INFORMATION_SCHEMA.EVENTS 表显示的是计划的作业
C错,INFORMATION_SCHEMA.SESSION_STATUS 表显示的是当前会话的变量及其变量值
9. A database exists as a read-intensive server that is operating with query_cache_type =DEMAND. The database is refreshed periodically, but the resultset size of the queries does not fluctuate.
—Note the following details about this environment:
A web application uses a limited set of queries.
The Query Cache hit rate is high.
All resultsets fit into the Query Cache.
All queries are configured to use the Query Cache successfully.
The response times for queries have recently started to increase. The cause for this has correctly been identified as the increase in the number of concurrent users accessing the web service. Based solely on the information provided, what is the most likely cause for this slowdown at the database level?
A. The Query Cache is pruning queries due to an increased number of requests.
B. Query_cache_min_res_unit has been exceeded, leading to an increased performance overhead due to additional memory block lookups.
C. Mutex contention on the Query Cache is forcing the queries to take longer due to its singlethreaded nature.
D. The average resultset of a query is increasing due to an increase in the number of users requiring SQL statement execution.
分析:
这是一个读密集型数据库,数据库会在一段时间后刷新,但是其查询的结果集大小波动不大。而所有结果集都在Query Cache中,且网页应用使用一套有限的查询语句。且Query Cache hit rate很高。
因此A,D错,请求通过的应用查询,查询语句数量有限,结果集都能放在Query Cache中,相同查询语句的请求不会增多Query Cache中的资源的占用,因此清理查询并非主要矛盾。
B也错,因此Query_cache_min_res_unit设置过大,仅会造成Query Cache中碎片过多。如果请求的结果集都能在Query Cache中,这就和碎片没什么关系了。
C正确,尽管官方文档中未大量解释Query Cache Mutex争用问题,在线程运行查询语句时,会在Query Cache中先获取Mutex锁,之后开始查询匹配的查询语句和结果集。如果找到后返回结果。
如果未找到匹配,在执行查询后,需要将查询语句和结果集插入Query Cache中,这也会需要获取锁。尽管这个时间所需非常短,但是在读密集的情况下,资源争用会导致线程排队等待现象。
10. You have a login-path named "adamlocal" that was created by using the mysql_config_editor command. You need to check what is defined for this login_path to ensure that it is correct for you deployment. You execute this command:
$ mysql_config_editor print –login-path=adamlocal
What is the expected output of this command?
A. The command prints all parameters for the login-path. The password is printed in plain text.
B. The command prints all parameters for the login-path. The password is shown only when you provide the --password option.
C. The command prints all parameter for the login-path. The password is replaced with stars.
D. The command prints the encrypted entry for the login-path. The is only possible to see if an entry exists.
分析:
mysql_config_editor工具命令用于建立外部登陆文件,一般由mysql客户端或应用来使用,好处在于登陆时免去输入登陆密码,密码已经被保存在了登陆文件中。在环境变量MYSQL_TEST_LOGIN_FILE未设置的情况下,mysql_config_editor默认文件名为.mylogin.cnf,且文件保存在执行此命令的用户home目录下。
登陆文件建立后,可直接使用以下命令登陆:
shell> mysql --login-path=login-path
当然,--login-path的默认值为client,因此如果你使用mysql_config_editer set --login-path=client 来进行用户密码设置设置,那么登陆所设用户的时候,连--login-path也可不用了:
shell> mysql
A, D错,因为不管如何,你都看不到密码的,密码被加密保存后,使用mysql_config_editor print会将密码替代以星号显示。
B错,使用mysql_config_editor --help可知在参数项中没有此--password项,且通过参考文档可知--password是用于设置密码而非显示密码的。
11. You are using replication and the binary log files on your master server consume a lot of disk space. Which two steps should you perform to safely remove some of the older binary log files?
A. Ensure that none of the attached slaves are using any of the binary logs you want to delete.
B. Use the command PURGE BINARY LOGS and specify a binary log file name or a date and time to remove unused files.
C. Execute the PURGE BINARY LOGE NOT USED command.
D. Remove all of the binary log files that have a modification date earlier than today.
E. Edit the .index file to remove the files you want to delete.
分析:
A是必须要保证的,你的删除的肯定不能正被slave使用啦。
PURGE LOGS语法PURGE { BINARY | MASTER } LOGS { TO 'log_name' | BEFORE datetime_expr },所做操作会对.index文件进行自动更新。因此B正确,E错。
C错,无此语法。
D错,具体清理到什么位置需要按照SHOW SLAVE STATUS来查看,而不是武断地确定删除早于今天的binary log文件。
12. Which two statements are true about InnoDB auto-increment locking?
A. The auto-increment lock can be a table-level lock.
B. InnoDB never uses table-level locks.
C. Some settings for innodb_autoinc_lock_mode can help reduce locking.
D. InnoDB always protects auto-increment updates with a table-level lock.
E. InnoDB does not use locks to enforce auto-increment uniqueness.
分析:
auto-increment的AUTO-INC锁是一个表级锁,因此A正确,B和E错误。
C正确,根据数据库参数innodb_autoinc_lock_mode的设置,插入操作会根据模式和所用语句的不同选用相应的锁。innodb_autoinc_lock_mode = 2的时候,将不使用表级锁和轻量mutex锁,不过在基于语句复制(SBR: Statement Based Replication)时,会有交错序列风险。
13. Consider the Mysql Enterprise Audit plugin. A CSV file called data.csv has 100 rows of data. The stored procedure prepare_db() has 10 auditable statements. You run the following statements in the mydb database:
Mysql> CALL prepare_db();
Mysql> LOAD DATA INFILE '/tmp/data.cav' INTO TABLE mytable;
Mysql> SHOW TABLES;
How many events are added to the audit log as a result of the preceding statements?
A. 102; top-level statements are logged, but LOAD DATA INFILE is logged as a separate event.
B. 3; only the top-level statements are logged.
C. 111; top-level statements and all lower-level statements are logged.
D. 12; only top-level statements and stored procedure events are logged.
分析:
audit.log文件中每个元素代表了一个事件,如客户连接或关闭连接事件,执行SQL语句等。
仅顶层语句会被记录下来,存储程序(如触发器或存储过程)中的语句不会被记录。
命令如LOAD DATA INFILE在进行操作时,其对文件内容进行进行操作的具体细节不会被记录。
14. You execute the following statement in a Microsoft Windows environment. There are no conflicts in the path name definitions.
C: \> mysqld –-install Mysql56 –-defaults–file=C:\my–opts.cnf
What is the expected outcome?
A. Mysqld acts as an MSI installer and installs the Mysql 5.6 version, with the c:\my-opts.cnf configuration file.
B. Mysql is installed as the Windows service name Mysql56, and uses c:\my-opts.cnf as the configuration file
C. An error message is issued because –-install is not a valid option for mysqld.
D. A running Mysql 5.6 installation has its runtime configuration updated with the server variables set in c:\my-opts.cnf.
分析:
首先mysqld是作为MySQL服务端主程序来运行的,它并不负责MSI安装的过程,因此A错。
通过mysqld --install可以进行Windows服务注册,同时--defaults-file用于设置启动服务端时使用的配置文件,B正确。
请注意--install命令项仅存在于Windows版MySQL的mysqld命令中,如果你是在Linux上安装MySQL是无法找到mysqld对应的--install命令项的。
C错误,因为其对于Windows版的mysqld是有效项。
D错,因此这命令不是用于安装时的配置。
16. What are four capabilities of the mysql client program?
A. Creating and dropping databases
B. Creating, dropping, and modifying tables and indexes
C. Shutting down the server by using the SHUTDOWN command
D. Creating and administering users
E. Displaying replication status information
F. Initiating a binary backup of the database by using the START BACKUP command
分析:
首先我们需要分清楚MySQL和mysql这两个词的概念,MySQL是指MySQL整个数据库和其软件,而mysql则是其软件中涵盖的一个客户端工具。
本题考的是对这些客户端工具使用。在使用mysql命令行工具登陆服务端后,可以执行的命令也非常多,比如建立和删除数据库,表和索引的增删改等。
你也可以使用mysql客户端工具来建立用户,并进行对用户的权限和访问进行管理。当然在Master-Slave Replication的主库和从库,你也可以使用show master status及show slave status来查看复制的状态情况。
因此, ABDE都是正确的。
至于关闭MySQL Server,这有多种方式,其中一种是使用mysqladmin客户端工具shutdown命令来实现的,mysql客户端工具不负责这事。
而备份,逻辑备份可使用mysqldump 或 mysqlpump(从MySQL 5.7.6开始)。而binary backup则可以使用mysqlbackup(如果你的MySQL是企业版的话)或使用copy表文件的方式来进行备份,而不是在mysql命令行工具中键入START BACKUP命令。
17. Assume that you want to know which Mysql Server options were set to custom values.
Which two methods would you use to find out?
A. Check the configuration files in the order in which they are read by the Mysql Server and compare them with default values.
B. Check the command-line options provided for the Mysql Server and compare them with default values.
C. Check the output of SHOW GLOBAL VARIABLES and compare it with default values.
D. Query the INFORMATION_SCHEMA.GLOBAL_VARIABLES table and compare the result with default values.
分析:
MySQL Server配置项由多处设置组成,由于Server的主程序为mysqld,因此其命令项设置也主要是看mysqld对应的项的设置。
在命令项设置后,启动后相应项反应在数据库上,就是那些Global Variables全局变量了,当用户会话访问时,其Session Variables则会copy自全局变量值,之后用户可以根据需要使用SET命令来修改会话变量。
当然如果有足够的权限,用户也可以修改全局变量,不过这种修改仅应用于正在运行MySQL Server,且对之后新登陆会话有效,一旦Server重启就打回原形了。
此题中,主要是希望查看启动后,使用的全局变量和其默认值修改情况,一般在启动初始化时,我们可以提前通过mysqld的命令行项上直接修改,或使用配置文件来进行启动时候的项的默认修改。
但是A, B都是错的,因为你无法确认MySQL Server的全局变量在启动后是否有人为被再次修改过。
C正确,因为show global variables可以了解当前所有全局变量值,从而和默认值进行比较。请注意:show variables指的是查看当前会话变量,因此一定要加上global。
D在MySQL 5.6版本中正确,因为其global variables值存放于此表中。不过在5.7版本,GLOBAL_VARIABLES这张表被移至performance_schema下,原先INFORMATION_SCHEMA.GLOBAL_VARIABLES将成为空表并被弃用。
18. You install a copy of Mysql 5.6.13 on a brand new Linux server by using RPM packages. The server starts successfully as verified by the following commands:
$ pidof mysqld 3132
$ tail – n2 /var/lib.mysql/hostname.err
2013-08-18 08:18:38 3132 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.13-enterprise-commercial-advanced' socket: '/tmp/mysql.sock' port: 3306
Mysql Enterprise Server – Advanced Edition (Commercial)
You attempt to log in as the root user with the following command:
$ mysql –u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Which statement is true about this scenario?
A. The RPM installation script sets a default password of password for new installations.
B. The local root user must log in with a blank password initially: mysql –u root –p.
C. New security measures mean that the mysql_secure_installation script must be run first on all new installations.
D. The mysql_install_db post-installation script used –-random-passwords.
分析:
MySQL5.6 Linux RPM包安装中会调用带有--random-passwords参数项的mysql_install_db脚本命令, 为root用户生成一个随机密码,并保存在$HOME/.mysql_secret文件中。
A错,生成的是一个随机密码,而非默认密码。B错,因为本地root用户已经有一个生成的密码了,因此空密码是不能登陆成功的。
C错,mysql_secure_installation是一个非必要脚本,在MySQL安装完成后,你可以运行此脚本来进一步增强其安全策略。
19. A Mysql Server has been running an existing application successfully for six months.The my.cnf is adjusted to contain the following additional configuration:
[mysqld]
default-authentication-plugin=sha256_password
The Mysql Server is restarted without error.
What effect will the new configuration have in existing accounts?
A. They will have their passwords updated on start-up to sha256_password format
B. They will have to change their password the next time they login to the server
C. They are not affected by this configuration changeZ
D. They all connect via the secure sha256_password algorithm without any configuration change.
分析:
default-authentication-plugin 的作用是为了在create user 时默认其所使用的密码加密格式。其和已经建立的用户所使用的密码格式无关,因此A,B错。
在客户端工具进行连接时,服务端会在 mysql.user 表中进行匹配,以了解对应登陆用户所使用的密码格式,并以此授权方式进行登陆验证,因此D错。
21. What are three actions performed by the mysql_secure_installation tool?
A. It prompts you to set the root user account password.
B. It checks whether file permissions are appropriate within datadir.
C. It asks to remove the test database, which is generated at installation time.
D. It can delete any anonymous accounts.
E. It verifies that all users are configuration with the longer password hash.
分析:
mysql_secure_installation脚本工具仅可做以下四件事:
1. 设置root用户密码
2. 去除root用户的非本地访问账号
3. 去除匿名用户账号
4. 去除test数据库。
22. Consider the query:
Mysql> SET @run = 15;
Mysql> EXPLAIN SELECT objective, stage, COUNT(stage) FROM iteminformation WHERE run=@run AND objective='7.1' GROUP BY objective,stage ORDER BY stage;
The iteminformation table has the following indexes;
Mysql> SHOW INDEXES FROM iteminformation:
This query is run several times in an application with different values in the WHERE clause in a growing data set.
What is the primary improvement that can be made for this scenario?
A. Execute the run_2 index because it has caused a conflict in the choice of key for this query.
B. Drop the run_2 index because it has caused a conflict in the choice of key for this query.
C. Do not pass a user variable in the WHERE clause because it limits the ability of the ptimizer to use indexes.
D. Add an index on the objective column so that is can be used in both the WHERE and GROUP BY operations.
E. Add a composite index on (run,objective,stage) to allow the query to fully utilize an index.
分析:
首先我们需要了解EXPLAIN命令执行后的输出含义,对应查询中Possible_Keys显示在查询时可使用Run和Run_2这两个索引来优化查询,Keys列则表明最终执行计划选择使用Run_2索引。
通过SHOW INDEXES FROM 命令,我们可以了解此表所有的索引,这里我们知道有Run(Run, Name)索引和Run_2(Run Stage)索引。
MySQL建立的联合索引,在利用这些索引时,你需要遵循leftmost prefix index(最左前缀索引)原则,即当你有一个索引为(col1, col2, col3),在查询时,查询条件中对(col1), (col1, col2)或(col1, col2, col3) 进行查询时可以使用到此索引。
由于Where中有run=@run,因此,索引Run和Run_2都满足被利用的条件,由于GROUP BY按规则无法利用这些索引,而ORDER BY则可以进一步利用stage索引,因此最终优化器选择使用Run_2索引。
A, B错,因此这种冲突说法不成立,因为索引的选择是由优化器选择的结果。C错,使用变量并不会对优化器使用索引进行限制。
D错,因此仅对objective列建立索引,并不会被GROUP BY使用。
E正确,因为建立(run,objective,stage)索引,此查询满足GROUP BY的Tight Index Scan规则,可以使用此索引提高查询性能。
23. Consider typical High Availability (HA) solutions that do not use shared storage.
Which three HA solutions do not use shared storage?
A. MySQL Replication
B. Distributed Replicated Block Device (DRBD) and Mysql
C. Windows Cluster and MySQL
D. Solaris Cluster and MySQL
E. MySQL NDB Cluster
分析:
从图中的Shared Nothing我们就可以知道MySQL Replication,MySQL Fabric,DRBD,MySQL Cluster都符合要求,既然什么都不会共享使用,那么存储也一样不会被共享啦。
24. Which three statements are characteristic of the MEMORY storage engine?
A. Each table is represented on disk as an .frm file.
B. Each table has a corresponding .MYI and .MYD file.
C. It can support foreign keys.
D. It cannot contain text or BLOB columns.
E. Table contents are not saved if the server is restarted.
F. It can support transactions
分析:
以MEMORY引擎建立的每张表都对应了一个以.frm为后缀的表定义文件。.MYI和.MYD对应的是以MyISAM引擎建立的的表的索引及数据文件。
MEMORY引擎不支持外键,不支持事务,也不支持TEXT和BLOB类型列。表会在服务端重启时被清空,一般作为临时工作及从其他表抽取的只读数据存放地处理。
25. Consider the MySQL Enterprise Audit plugin.The following event detail is found in the audit log:
TIMESTAMP="2013-04-09t01:54:17"
NAME="Connect"
CONNECTION_ID="3"
STATUS="1045"
USER="kate"
PROXY_USER=""
HOST="localhost"
IP=""
DB=""/>
Which two points can be concluded from the given event?
A. A connection was blocked by a firewall or a similar security mechanism.
B. A connection was attempted via socket rather than TCP.
C. A connection failed because the proxy user privileges did not match the login user.
D. A connection as the user kate was successful.
E. A connection failed due to authentication being unsuccessful.
分析:
首先对于localhost的本地连接,是使用socket连接方式,因此B正确。
STATUS为1045,通过perror我们可以知道,报错为访问授权错误,说明可能登陆密码输入错误,这和防火墙没有关系,因此A错,E正确。
C错,PROXY_USER为空值,索引请登陆并未使用proxy user。
D错,STATUS为1045,因此访问是失败的,执行报错。
27. You are having problems with connections from a specific host (192.168.1.15) not closing down correctly.
You want to find the state of the threads from that host check for long-running queries.
Which statement will accomplish this?
A. SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE HOST='192.168.1.15';
B. SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE HOST='192.168.1.15';
C. SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE HOST='192.168.1.15';
D. SELECT * FROM INFORMATION_SCHEMA.INNODB_METEICS WHERE HOST='192.168.1.15';
分析:
INFORMATION_SCHEMA.PROCESSLIST提供了正在运行线程的相关信息
INFORMATION_SCHEMA.EVENTS此表存放关于计划调度事件信息
INFORMATION_SCHEMA.STATISTICS此表存放数据库表索引信息INFORMATION_SCHEMA.INNODB_METRICS存放InnoDB性能相关信息
28. Identify a performance impact when using the Performance Schema.
A. There is no impact on performance.
B. There is an overhead for querying the Performance Schema but not for having it enabled.
C. There is a constant overhead regardless of settings and workload.
D. The overhead depends on the settings of the Performance Schema.
分析:
A错,启用performance shema会对系统性能进行监控并进行事件记录,因此这些功能自然会带来一些额外的开销,这样会对性能有一定的影响,不过和用来进行性能分析和诊断的好处相比,这些开销又是值得的。
当启动performance schema, 相应的一些默认的instruments也会被启用,所以B错。
C错,D正确,根据你启用的instruments多少,相应的开销会有不同,这取决于你的设置。
29. Which statement is true about FLUSH LOGS command?
A. It requires the RELOAD, FILE, and DROP privileges.
B. It closes and reopens all log files.
C. It closes and sends binary log files to slave servers.
D. It flushes dirty pages in the buffer pool to the REDO logs.
分析:
A错,FLUSH 语法必须要有RELOAD权限,除此之外针对特定FLUSH语法还会要求有SELECT及LOCK TABLES权限。
B正确,默认在不指定何种日志的情况下,会对所有日志进行关闭并开启新的日志。
C错,此语句并不会将binary log发送到slave服务端。
D错,对于innoDB引擎支持的表,FLUSH TABLES会将dirty pages从buffer pool中刷出到表数据文件中。
30. Which two are correct steps in taking a binary backup of MyISAM tables?
A. Always stop the server prior to the backup.
B. Stop the server or lock the tables prior to the backup.
C. Stop the server or lock the databases prior to the backup.
D. Make a copy of the .frm, .myd, and the .myi files.
E. Make a copy of the binary log and tablespace files.
分析:
对于MyISAM引擎的表的binary备份,你可以先使用以下命令锁表:
FLUSH TABLES tbl_list WITH READ LOCK;
然后拷贝对应表的.frm,.myd和.myi文件来进行备份。因此A,C错,因为没有必要。E错,因为这是针对InnoDB引擎的表说的。
31. You want to start monitoring statistics on the distribution of storage engines that are being used and the average sizes of tables in the various databases. Some details are as follows:
The MySQL instance has 400 databases. Each database on an average consists of 25-50 tables. You use the query:
explain SELECT TABLE_SCHEMA,'ENGINE',COUNT(*),SUM(data_length) total_size FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' GROUP BY TABLE_SCHEMA, 'ENGINE';
Why is this query slow to execute?
A. Counting and summarizing all table pages in the InnoDB shared tablespace is time consuming.
B. Collecting information requires various disk-level operations and is time consuming.
C. Aggregating details from various storage engine caches for the final output is time consuming.
D. Collecting information requires large numbers of locks on various INFORMATION_SCHEMA tables.
分析:
INFORMATION_SCHEMA数据库下的表都是虚拟表(可以看作是视图),它们都是通过收集各种对象信息动态生成的。
其中INFORMATION_SCHEMA.TABLES表的信息查询,对于需要对底层文件进行scan操作因此尤其花时间。
而通过explain此查询语句可知,此语句属于Open_full_table优化类(OPEN_FULL_TABLE: The unoptimized information lookup. The .frm, .MYD, and .MYI files must be opened.),由于并没有在where条件中对TABLE_SCHEMA及TABLE_NAME做任何常值限定,因此是做全库扫描,且对于每个表对应相关的物理文件也会打开扫描,因此性能会比较差。
32. Which two events will cause a slave server to create a new relay log file?
A. Starting of the I/O thread
B. Execution of the FLUSH LOGS statement
C. Starting of the SQL thread
D. Reaching the slave_pending_jobs_size_max limit
E. Execution of FLUSH TABLES WITH READ LOCK
分析:
I/O thread是从Master读取到的SQL Event写入relay log, 然后SQL thread读取relay log后写入Slave。
A slave server creates a new relay log file under the following conditions:
1) Each time the I/O thread starts.
2) When the logs are flushed; for example, with FLUSH LOGS or mysqladmin flush-logs.
3) When the size of the current relay log file becomes “too large,” determined as follows:
If the value of max_relay_log_size is greater than 0, that is the maximum relay log file size.
If the value of max_relay_log_size is 0, max_binlog_size determines the maximum relay log file size.
33. The InnoDB engine has a feature known as clustered indexes. Which three statements are true about clustered indexes as used in InnoDB?
A. A primary key must exist for creation of a clustered index.
B. A primary key is used as a clustered index.
C. A clustered index is a grouping of indexes from different tables into a global index for faster searching.
D. If no indexes exist, a hidden clustered index is generated based on row IDs.
E. A clustered index provides direct access to a page containing row data.
F. The first unique index is always used as a clustered index and not a primary key.
G. A clustered index allows fulltext searching within InnoDB.
分析:
根据参考中的说明,clustered index的生成条件中,primary key不是必须的。如果不存在primary key和unique key,则其会自己会生成一个隐藏的clustered index。因此A错,D正确。
C错,因为这不是作为多表的全局索引。F错,B正确,因为存在primary key的情况下,会首先将primary key作为clustered index。
E说法正确。G错,因为fulltext search需要建立的是FULLTEXT索引,而全文索引是inverted index design.和clustered index不同。
34. Which hardware storage option, when set up with redundant disks, offers the least stability, availability, and reliability for Mysql data?
A. RAID 5
B. iSCSI
C. SAN (Storage Area Network)
D. NFS (Networked File System)
分析:
参考文章中多次提到了NFS的许多缺点,不建议MySQL数据存放于NFS上。
If reliability is a consideration for your data, do not configure InnoDB to use data files or log files on NFS volumes.
Potential problems vary according to OS and version of NFS, and include such issues as lack of protection from conflicting writes, and limitations on maximum file sizes.
Even when the preceding precautions are observed, this kind of setup works only with MyISAM and MERGE tables, and not with any of the other storage engines.
Also, this warning against sharing a data directory among servers always applies in an NFS environment.
Permitting multiple MySQL servers to access a common data directory over NFS is a very bad idea.
The primary problem is that NFS is the speed bottleneck. It is not meant for such use.
Another risk with NFS is that you must devise a way to ensure that two or more servers do not interfere with each other.
Usually NFS file locking is handled by the lockd daemon, but at the moment there is no platform that performs locking 100% reliably in every situation.
It is not a good idea to configure InnoDB to use data files or log files on NFS volumes. Otherwise, the files might be locked by other processes and become unavailable for use by MySQL.
Do not put MySQL tables on an NFS-mounted volume.
NFS uses a message-passing protocol to write to files, which could cause data inconsistency if network messages are lost or received out of order.
35. A Mysql instance is running on a dedicated server. Developers access the server from the same network subnet. Users access the database through an application that is running on a separate server in a DMZ.
Which two will optimize the security of this setup?
A. Disabling connections from named pipes or socket files (depending on the operating system of the server)
B. Running the server with –-skip-networking specified
C. Limiting logins to originate from the application server or the server’s subnet
D. Starting the server with –-bind-address=0.0.0.0 specified
E. Installing Mysql on the application server, and running the database and application on the same server
F. Enabling and using SSL for connections to the Mysql database
分析:
由图可知,使用–-skip-networking将使得仅允许本地连接,而–-bind-address=0.0.0.0绑定ip,则使得TCP/IP连接的用户及应用都被无法访问了,因此这不是安全问题了,而是完全不能访问了,因此B,D错。
A错,named pipes或socke文件都是用于本地连接的,而非用于外部访问,因此只是增加麻烦,而不是提升外部访问安全性。
E错,因为这里安全性和应用及数据库、客户端的安装位置无关。
C正确,因为用户可以通过应用账户访问应用,而应用内部则可以仅使用一个或几个已为应用建立的数据库账号来访问MySQL。从而控制了访问源,增加了一层安全性。
F正确,SSL连接协议是一种加密连接,因此使用SSL连接MySQL增加了安全性。
38. User A issues the command:
LOCK TABLES pet READ;
Which command can User B execute against the pet table?
A. UPDATE pet…
B. SELECT….FROM pet
C. INSERT INTO pet…
D. ALTER TABLE pet…
分析:
READ锁:
1)获取此锁的会话可以读取锁对应的表(但是不能进行写操作)。
2)其他多个会话也可以在同时获取此表的READ锁。
3)其他会话可以在读取此表时不显式要求获取READ锁。
从以上说明中得出B正确,
由于UPDATE, INSERT, ALTER都会对表数据或表结构进行修改,因此在表被锁住的情况下,其他会话执行相关修改语句会hang住,因此A,C,D错。
39. When backing up a replication slave, which three should also be backed up in addition to data?
A. The master.info and relay-log.info files
B. The relay log files
C. The relay index file
D. mysql.slave_master_info table
E. mysql.slave_relay_log_info table
F. mysql.slave_worker_info table
分析:
如果对MySQL进行了设置,那么可以将相应master.info和relay-log.info状态信息文件中的信息存入mysql.slave_master_info和 mysql.slave_relay_log_info表中,但是题目中提到除了数据文件之外需要备份的文件。
这两个表实际上已经涵盖于数据文件中,因此此题目所指的其实是在其它的文件,D和E错误。那么(在非信息表存放的情况下)A首先是需要的,relay log文件也需要备份,因为恢复slave的时候也需要,B正确。当然如果slave过旧,也需要考虑master的binary log备份需要。
relay index文件存放的是当前可用的relay log文件,它和binary index文件的作用其实一样,如果没有这个文件,那么你的relay log文件都不会被你的slave所识别了,理论上也应该备份下,当然如果真没有备份的话,那么就需要你在恢复的时候手工新建这个文件,将relay log文件名加入到这个文件中了,因此C正确。
mysql.slave_worker_info表和备份方面无关,因此F错。
40. You want to shutdown a running Mysql Server cleanly.
Which three commands that are valid on either Windows or Linux will achieve this?
A. shell> pkill –u mysql mysqld_safe
B. shell> service mysql safe_exit
C. shell> /etc/init.d/mysql stop
D. shell> mysqladmin –u root –p shutdown
E. mysql> STOP PROCESS mysqld;
F. shell> net stop mysql
G. shell> nmc mysql shutdown
分析:
A错,pkill是可以杀进程,但是对符合模式匹配的进程,-u是找对应的有效用户id下进程,因此这种写法就是错误的。如果要关也应该写为pkill -15 mysqld。
查看/etc/init.d/mysql脚本逻辑(以Ubuntu版本MySQL为例)可知,关闭数据库的本质同样使用类似的kill命令:
B错,从UbuntuBootupHowto参考文档中,我们可以了解service命令是Upstart程序启动关闭服务所使用的命令,其实质继承了/etc/init.d中的服务脚本,而脚本设计规则一般使用的子命令为start, stop, status等,不存在safe_exit子命令。
同样从参考中我们可以了解C正确。
D正确,mysqladmin作为客户端工具,需要登录后才能执行之后的子命令,而shutdown正是mysqladmin作为MySQL数据库管理工具关闭数据库的操作子命令。
E和G错,无此命令。
F正确,当MySQL server以Windows服务进行了注册,就可以使用net命令来对服务进行启动关闭(注意使用net命令需要使用以管理员身份打开的CMD窗口)。
41. What are two methods of taking a binary backup of a Mysql Server using InnoDB storage engine?
A. MySQL Enterprise Backup
B. mysqldump with –-binary-data option
C. mysqlhotcopy
D. File system snapshots
E. mysqldumpslow
分析:
A正确,因为此为企业级MySQL热备工具,且进行的是物理备份,支持InnoDB存储引擎表的备份。
B错,无此参数项,且mysqldump是用于做逻辑备份的。E错,因为mysqldumpslow是对MySQL Slow Query Log的解析和归总。
C错,mysqlhotcopy可用于备份MyISAM和ARCHIVE存储引擎表,其内部使用cp和scp命令来进行文件拷贝备份,虽然是二进制备份,但是并非是针对InnoDB表的备份,需要注意的是此工具从MySQL 5.6.20开始被过气,在MySQL 5.7中被完全移除了。
D正确,文件系统快照(File system snapshots),这是许多大企业选择的方案,因为系统级的快照速度很快,且可作为二进制备份。
42. Consider the following table:
CREATE TABLE games(id int (10) unsigned NOT NULL AUTO_INCREMENT,
keyword varchar (45) DEFAULT NULL,
date datetime NOT NULL,
PRIMARY KEY (id, date),
UNIQUE KEY keyword_idx(keyword, date)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITION BY RANGE (TO_DAYS(date))(
PARTITION g201301 VALUES LESS THAN (TO_DAYS('2013-01-01 00:00:00')),
PARTITION g201302 VALUES LESS THAN (TO_DAYS('2013-02-01 00:00:00')),
PARTITION g201303 VALUES LESS THAN (TO_DAYS('2013-03-01 00:00:00')),
PARTITION g201304 VALUES LESS THAN (TO_DAYS('2013-04-01 00:00:00')),
PARTITION gMORES VALUES LESS THAN (MAXVALUE));
Which method should be used to add a new g201305 partition to the table?
A. ALTER TABLE games
REORGANIZE PARTITION gMORES INTO (
PARTITION g201305 VALUES LESS THAN (TO_DAYS('2013-05-01 00:00:00')),
PARTITION gMORES VALUES LESS THAN (MAXVALUE)
);
B. ALTER TABLE games ADD PARTITION g201350 VALUES LESS THAN (TO_DAYS('2013-05-01 00:00:00'));
C. ALTER TABLE games
COALESCE PARTITION gMORES INTO PARTITION g201305 VALUES LESS THAN (TO_DAYS('2013-05-01 00:00:00')),
PARTITION gMORES VALUES LESS THAN (MAXVALUE));
D. ALTER TABLE games
SPLIT PARTITION gMORES INTO (
PARTITION g201305 VALUES LESS THAN (TO_DAYS('2013-05-01 00:00:00')),
PARTITION gMORES VALUES LESS THAN (MAXVALUE));
E. ALTER TABLE games
DROP PARTITION gMORES,
ADD PARTITION (
PARTITION g201305 VALUES LESS THAN (TO_DAYS('2013-05-01 00:00:00')),
PARTITION gMORES VALUES LESS THAN (MAXVALUE));
分析:
由于在表分区定义时,已经定义了MAXVALUE的存放分区,而ADD PARTITION在设置时必须值更大于MAXVALUE,这显然是不可能的,因此B错。在对已存分区进行重新分区时,没有SPLIT PARTITION这种语法,而使用的REORGANIZE PARTITION partition_names INTO (partition_definitions)这样的语法,因此D错,A正确。
对于COALESCE PARTITION语法,主要用于控制HASH或KEY的自动分区数量,并无对特定种分区进行的分区语法,C错。
从参考中,我们知道ADD PARTITION, DROP PARTITION, COALESCE PARTITION, REORGANIZE PARTITION, ANALYZE PARTITION, CHECK PARTITION, and REPAIR PARTITION options cannot be combined with other alter specifications in a single ALTER TABLE, since the options just listed act on individual partitions.
即一个ALTER TABLE语法中,不可同时进行这些操作,需要分开执行,因此E错,如果分开执行就可成功。
43. Full Atomicity, Consistency, Isolation, Durability (ACID) compliance is a necessity for a new application, which heavily reads and writes data.
This requires the following config file options:
sync_binlog=1
innodb_flush_log_at_trx_commit=1
innodb_doublewrite=1
However, this configuration is expected to introduce disk I/O overhead.
What three changes will reduce disk I/O overheads?
A. Use of soft links for database directories on the same physical disk
B. Use of separate directories on the same physical disk for log files and data files
C. Placement of InnoDB log files and datadir on separate physical disks
D. Allocation of RAM to the buffer pool such that more of the data can fit in RAM
E. Use of delay_key_write=ON for batch index update
分析:
所谓ACID,即是指事务的原子性(Atomicity)、一致性(Consistency)、隔离性(Isolation)、持久性(Durability)。
首先我们来了解下所提到的几个参数:
sync_binlog用于保证在事务commit前,binary log从日志缓冲中flush到磁盘进行操作的binary log commit group的数量,0代表仅靠系统自有机制从系统缓存中刷到磁盘,1代表在所有事务commit前,其相应日志都被落地,大于1的值表示多个binary log commit group协同工作以保证日志落地,因此0和大于1的值,都会有丢失binary log记录的风险,其中MySQL 5.7.7之前其默认值为0,而之后默认值为1,虽然1的安全性更高,但性能也会消耗更多。
innodb_flush_log_at_trx_commit用于InnoDB log buffer到磁盘log file落地的执行机制,1表示严格遵从ACID,一旦事务commit,就会将InnoDB日志落地到磁盘中。0则是依靠系统自有机制进行从缓冲到磁盘的落地保证,2则log file缓冲会每隔N秒进行一次落地,N取决于innodb_flush_log_at_timeout参数设置,0和2都在服务端或系统奔溃后有丢失日志记录风险。
innodb_doublewrite是一种数据文件磁盘保存时的一种安全保存机制,主要是避免由于InnoDB page和OS block size大小不同,可能在进行I/O操作时候,由于各种奔溃问题造成的partial page write。
在学习了这些参数后,我们来了解下这一题。A错,从官方文档可知,软链接(symbolic-links)可用于对于MyISAM引擎支持的表,但是前提是你的表示分布在不同的物理磁盘上,因为磁盘驱动是读写的瓶颈,因此放置在不同磁盘上,那就是将工作分给了多个磁盘驱动,因此不难理解B也是错的,而C是正确的。
D正确,因为buffer pool分配合理确实可以减少I/O的读写操作。
E正确,delay_key_write=ON表示对于启用DELAY_KEY_WRITE的MyISAM表,推迟其表索引的更新的缓存落地,直到表被关闭时才进行,这会在一定程度少减少并加快索引键缓存的I/O落地操作。
44. You want a record of all queries that are not using indexes.
How would you achieve this?
A. By enabling the Slow Query Log because all queries that are not using indexes will be logged automatically
B. By enabling the Error Log because not using indexes is an error
C. By enabling the Slow Query Log and using the --log-queries-not-using-indexes option
D. By enabling the Error Log and using the --log-queries-not-using-indexes option
分析:
To include queries that do not use indexes for row lookups in the statements written to the slow query log, enable the log_queries_not_using_indexes system variable.
Error Log并不是用于记录慢查询的。
45. The validate_password plugin is loaded and displays the following settings in global variables:
mysql> SHOW VARIABLES LIKE 'validate_password%';
When attempting to set your password, you get the following error:
mysql> SET PASSWORD = PASSWORD('Hoverl@%');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
What is the cause of the error?
A. The password is eight characters long, but needs to exceed validate_password_length to be valid.
B. All of the MEDIUM password policy requirements have not been honored.
C. The password matches a substring Hover as a dictionary word.
D. The password does not match the validate_passoword_number_count requirement.
E. There is no dictionary file defined, so password validation cannot work as expected.
分析:
validate_password_length值代表密码至少应该为8个字符,因此A说的需要8位超出才有效,是不对的,8位也可。validate_password_policy为MEDIUM,而这里设置的密码Hoverl@%实际上部分符合要求,但不是所有都不符合,因此B错。
C错,因为validate_password_policy为STRONG时,才会检查dictionary文件。
D正确,这里的密码中至少应该有2个以上数字值。
E错,dictionary文件仅用于validate_password_policy为STRONG的情况。注意,SET PASSWORD = PASSWORD('') 在MySQL 5.7版本开始过时,在最新版本也可直接使用SET PASSWORD = ''语法。
46. You attempt to connect to a MySQL Server by using the mysql program. However, you receive the following notice:
ERROR 2059 (HY000): Authentication plugin ‘mysql_clear_password’ cannot be loaded: plugin not enabled
What would you run to fix the issue?
A. The mysql client with the –-ignore-password-hashing option
B. The mysql_secure_installation script to update server security settings
C. The mysql client with the –-enable-cleartext-plugin option
D. The mysql_upgrade script
E. The install plugin command for the mysql_cleartext_password plugin
分析:
A错,mysql客户端工具并没有–-ignore-password-hashing这个命令项。B错,mysql_secure_installation脚本被用于MySQL数据库安装后的一个安全增强处理,但其不涉及关于plugin的使用。
D错,因为mysql_upgrade是对表的检查和升级,而非对mysql_clear_password这类内置库升级。
E错,mysql_clear_password为内置功能(内置于libmysqlclient客户端库中),因此无插件文件存在,不需要进行安装,仅需要启用即可。
从此报错,我们可以联想到首先其不是单纯的Cleartext客户端授权插件启用后,所引发的问题。因为只有在mysql客户端程序使用了–-enable-cleartext-plugin之后,或Unix/Linux系统环境使用了LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN后,才会进行明文密码功能检查,才有可能出现此报错。
因此,既然抱了这个错,说们要么我们已经使用了–-enable-cleartext-plugin,要么已经使用了LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN来启用了功能。从这个角度看,C这个答案某些奇怪,不知道对错。
但是如果我们了解到一般报这个错的大背景后,就会明白了C为什么是正确的了。此报错一般是指启用了PAM插件后,而没有同时启用Cleartext客户端授权插件造成了。这样的话,C说的使用–-enable-cleartext-plugin进行登陆的解决方案就说得通了。
47. The following commands are available in the Linux binary distributions of MySQL:
mysqld
mysqld_safe
mysql.server
What is the correct description of each of these commands?
A. mysqld is the server.
mysqld_safe is a shell script that invokes mysqld.
mysql.server is a wrapper for mysql_safe.
B. mysqld is a shell script that starts mysql.server.
mysqld_safe causes the server to start up in data recovery mode.
mysql.server is the server.
C. mysqld is the server.
mysqld_safe causes the server to start up in data recovery mode.
mysql.server is a wrapper for mysqld_safe.
D. mysql, mysqld.safe, and mysql.server reside in different locations but are all symlinked to the same script.
分析:
mysqld_safe是一个shell脚本,其中会通过执行mysqld来启动数据库服务端。而mysqld作为MySQL服务端程序,它不是一个脚本,因此B和D错误。
mysql.server也是一个shell脚本,其中调用mysqld_safe来启动MySQL服务端,而此脚本也一般作为系统启动脚本来进行部署使用,相关设置可以查看参考链接。
48. Which three statements describe how the strict SQL mode provides added security?
A. It rejects statements that try to insert out-of-range values.
B. It rejects invalid dates.
C. It limits the operations that the server can perform.
D. It rejects queries that produce out-of-range values.
E. It rejects dates with zero day or month values.
分析:
When this manual refers to “strict mode,” it means a mode with either or both STRICT_TRANS_TABLES or STRICT_ALL_TABLES enabled.
一般Strict SQL Mode还会涉及到一些其它模式,不过如果你设置sql_mode为TRADITIONAL,其所包括的模式就基本涵盖了Strict SQL Mode的要求了。
SQL Mode本身并不会限制服务端的操作,而是会改变服务端对语句执行所表现的行为进行调整和数据规范检查,按不同的mode做出反馈,因此C错。
D错,因为主要针对的是在data-change statements发生的无效值和缺值情况,查询语句所产生的超出范围值仅会被修正并警告,但不会被拒绝查询。
ABE正确,主要原因可查看参考链接中Strict SQL Mode的说明,不过对于非事务表,STRICT_ALL_TABLES和STRICT_TRANS_TABLES的SQL模式会有差异,因此此题出得并不严谨。
49. Following a server crash, the automatic recovery of InnoDB fails.
How would you begin to manually repair the InnoDB tables?
A. Start the server with the –-innodb_force_recovery option set to a non-zero value.
B. Start the server as usual, and then execute the REPAIR TABLE command.
C. Start the server as usual, and then execute the CHECK TABLE command.
D. Start the server with the –-innodb_recover_options option set to FORCE.
分析:
In most situations, even if the MySQL server was killed unexpectedly in the middle of heavy activity, the recovery process happens automatically and no action is needed from the DBA.
If a hardware failure or severe system error corrupted InnoDB data, MySQL might refuse to start. 这时候你就需要考虑通过跳过自动恢复中的某些步骤来进行强行启动。A正确,D错误,无–-innodb_recover_options项。
B和C也错,因为MySQL都起不来,这些命令你也用不了。而且REPAIR TABLE并不支持InnoDB。
50. What are three methods to reduce MySQL server exposure to remote connections?
A. Setting --skip-networking when remote connections are not required
B. Using the sql_mode=STRICT_SECURE after connections are established for encrypted communications
C. Setting specific GRANT privilege to limit remote authentication
D. Setting --mysql_secure_configuration to enable paranoid mode
E. Using SSL when transporting data over remote networks
分析:
B和D都错,无此sql mode和MySQL启动参数。
--skip-networking禁用了对所有TCP/IP连接的监听,因此远程连接直接被拒绝了。
GRANT权限则可以限制对使用远程连接的用户的访问权限,从而降低MySQL服务端数据库信息暴露。
启用SSL能在网络数据传递中起到加密保护作用。
52. A user has deleted the wrong row in a table and you are preparing a point-in-time recovery skipping the DELETE event.
The server is configured with:
You have identified that the DELETE statement to skip has the Global Transaction Identifier(GTID) 'dbbe07da-fe25-11e2-b6c7-0800274aa49e:5' and you replay the binary log with:
mysqlbinlog –-exclude-gtids='dbbe07da-fe25-11e2-b6c7-0800274aa49e:5' binlog.00000.2 | mysql
However all events were skipped instead of just the one deleting the wrong row.
What is the reason for this?
A. mysqlbinlog ignores arguments to –-exclude-gtids, it means ignore all events with GTIDs.
B. The server keeps track of which GTIDs have already been executed and skips those.
C. enforce_gtid_consistency is set to ON.
D. gtid_mode must be set to AUTO during point in time recoveries.
53. You have been notified that the ‘apps’.‘reports’ table has been accidentally truncated.You have single file mysqldump backup available taken prior to the truncate.The backup contains all the tables from the instance, and the ‘apps’.‘reports’ table must be restored without affecting the other remaining databases and tables.
Which restore option is suitable in this scenario?
A. Restore the backup to another databases instance and obtain a copy of the reports table individually.
B. Extract the ‘apps’.‘reports’ table from the backup using the SOURCE command.
C. Execute LOAD DATA INFILE ‘backup.sql’ SCHEMA=‘apps’ TABLE=‘reports’
D. Execute mysqldump on the backup.sql file and apply filter arguments to obtain only the ‘apps’.‘reports’ table.
分析:
B错,source命令仅能完整读取mysql脚本文件,不能进行单独命令提取,而备份文件中包括了数据库中所有表结构和数据内容,因此source命令不能满足要求。
C错,LOAD DATA INFILE无此语法,且被倒入的文件为单纯的数据平文件,而非mysqldump导出的命令行形式备份文件。
D错,mysqldump工具是对数据库中对象的备份导出,而不是对备份文件所做的操作。
A是一种可行的办法,不过还有一种方法,你可以直接打开这个备份文件,然后找到对应apps.reports的建表命令和数据插入命令,将其拷贝出来,然后单独执行即可。
54. You have forgotten the root user account password. You decide to reset the password and execute the following:
Shell> /etc/init.d/mysql stop
Shell> /etc/init.d/mysql start –-skip-grant-tables
Which additional argument makes this operation safer?
A. –-skip-networking, to prohibit access from remote locations
B. –-reset-grant-tables, to start the server with only the mysql database accessible
C. –-read-only,to set all data to read-only except for super users
D. –-old-passwords, to start MySQL to use the old password format while running without the grant tables
分析:
Stop the MySQL server if necessary, then restart it with the --skip-grant-tables option.
This enables anyone to connect without a password and with all privileges, and disables account-management statements such as ALTER USER and SET PASSWORD.
Because this is insecure, you might want to use --skip-grant-tables in conjunction with --skip-networking to prevent remote clients from connecting.
关于–-skip-grant-tables, 可以将其写在配置文件中启用。
不过由于登陆后并未倒入账号管理功能,因此ALTER USER和SET PASSWORD命令会被无效化,想要重新设置root密码。记得使用flush privileges来重新加载账号管理功能。
55. Which two requirements would lead towards a high availability solution?
A. When uptime is critical
B. When data must be refactored
C. When application concurrency is static
D. When data loss is unacceptable
E. When application is a single point of failure
分析:
对于高可用的需求一般基于两点,一个是减少downtime,一个防止是单点故障,不过保障数据不丢失也不能算错吧(除非你都没备份...)。所以此题仁者见仁。
56. Which statement is true about using Microsoft Windows Cluster as a platform for Mysql?
A. It is provided by means of IP-level disk replication.
B. It is shared-nothing architecture.
C. It implements High Availability by using the .NET Connector’s load balancing capabilities.
D. It relies on the shared disk architecture being visible to both servers.
57. You have enabled the Slow Query Log for a short period.
When you process the Slow Query Log, you receive the following snip of output:
Count: 100 Time=0.22s (22s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost
CREATE TABLE t1 (id serial ,id0 varchar(N) unique key ,intcol1 INT (N)
,intcol2 INT(N) ,intcol3 INT(N) ,intcol4 INT(N) ,intcol5 INT(N)
,charcol1 VARCHAR(N) ,charcol2 VARCHAR(N) charcol3 VARCHAR(N)
,charcol4 VARCHAR(N) ,charcol5 VARCHAR(N) charcol6 VARCHAR(N)
,charcol7 VARCHAR(N) ,charcol8 VARCHAR(N) charcol9 VARCHAR(N) ,
charcol10 VARCHAR(N))
Count: 64000 Time=0.02s (1213s) Lock=0.00s (6s) Rows=1.0 (64000), root[root]@localhost
SELECT intcol1, intcol2, intcol3, intcol4, intcol5, intcol6,intcol7, intcol8,intcol9, intcol10, charcol1, charcol2, charcol3, charcol4, charcol5, charcol6,charcol7, charcol8, charcol9, charcol10 FROM t1 WHERE id = 's'
Count: 1 Time=0.02s (0s) Lock=0.00s (0s) Rows=1.0 (1) agent[agent]@localhost
SELECT Select_priv, Repl_client_priv, Show_db_priv, Super_priv, Process_priv FROM mysql.user WHERE CONCAT(user, '@', host) = CURRENT_USER ()
Count: 48000 Time=0.02s (778s) Lock=0.00 (3s) Rows=1.0 (48000), root[root]@localhost
SELECT intcol1, intcol2, intcol3, intcol4, intcol5, charcol1, charcol2, charcol3,charcol4, charcol5, charcol6, charcol7, charcol8, charcol9, charcol10 FROM t1 WHERE id = 's'
You want to tune the query such that it provides the greatest overall time savings.
Which query will accomplish this?
A.
CHEATE TABLE t1 (id serial, id0 varchar(N) unique key, intcol1 INT(N),intcol2 INT (N), intcol3 INT(N) ,intcol4 INT(N), intcol5 INT(N), charcol1 VARCHAR(N),charcol2 VARCHAR (N), charcol3 VARCHAR(N), charcol4 VARCHAR(N), charcol5 VARCHAR(N),charcol6 VARCHAR (N), charcol7 VARCHAR(N), charcol8 VARCHAR(N), charcol9 VARCHAR(N),charcol10 VARCHAR (N);
B.
SELECT intcol1, intcol2, intcol3, intcol4, intcol5, intcol6, intcol7, intcol8, intcol9,intcol10, intcol11, intcol12, intcol13, intcol14, intcol15, intcol16, intcol17, intcol18, intcol19, charcol10 FROM t1 WHERE id = 's';
C.
SELECT Select_priv, Repl_client_priv, Show_db_priv, Super_priv, Process_priv FROM mysql.user WHERE CONCAT(user,'@', host) = CURRENT_USER();
D.
SELECT intcol1, intcol2, intcol3, intcol4, intcol5, charcol1, charcol2, charcol3, charcol4,charcol5, charcol6, charcol7, charcol8, charcol9, charcol10 FROM t1 WHERE id = 's';
分析:
首先是一些和本题无直接关联的零碎知识点理解:
SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.
然后我们来理解下题意,首先要注意的是我们得到的内容并不是slow query log文件中的直接内容,而是通过使用mysqldumpslow工具命令来读取slow query log文件所得的分类总结内容。
按照题意,你需要对所执行的SQL语句进行调优来整体节约执行时间,且这个选择题需要找到那个最能节约时间的查询。
我们看到花时间最多的是第二个查询,它被反复执行了64000次,总用时1213s,选择C可以直接排除,因为只被执行过一次,且耗时0.02s,怎么调优也不像是能大幅度节约时间的样子。
有的同学可能会想既然B,D项这些查询都是针对t1表,那么就应该选A,优化表的建立来影响其他对于此表的查询,这样就能总体节约时间。
但此题应该是一个比较明确的答案,而非这么摸棱两可,而且给id列建立索引,而进行等值连接的是's'字符,无法使用到索引。
58. Review the definition of the phone_list view.
CHEATE OR REPLACE
ALGORITHM=MERGE
DEFINER= 'root'@'localhost'
SQL SECURITY DEFINER
VIEW phone_list AS
SELECT e.id as id, e.first_name AS first_name, e.last_name AS last_name, coalesce(ph1.phone_no, '--') AS office_no, coalesce(ph2.phone_no, '--') AS cell_no
FROM employees e
LEFT JOIN employee_phone ph1
ON ph1.emp_id = e.id AND ph1.type = 'office'
LEFT JOIN employee_phone ph2 ON ph2.emp_id = e.id AND ph2.type = 'mobile'
The tables employees and employee_phone are InnoDB tables; all columns are used in this view.
The contents of the phone_list view are as follows:
mysql> select * from phone_list;
1 row in set (0.00 sec)
Which method can you use to change the cell_no value to ‘555-8888’ for John Doe?
A. DELETE FROM phone_list WHERE first_name='John' and last_name='Doe';
INSERT INTO phone_list (first_name, last_name, office_no, cell_no) VALUES ('John','Doe','X1234', '555-8888');
B. INSERT INTO employee_phone (emp_id, phone_no, type) VALUES (1,'555-8888','mobile');
C. UPDATE phone_list SET cell_no='555-8888' WHERE first_name='John' and last_name= 'Doe';
D. UPDATE employee_phone SET phone_no='555-8888' where emp_id=1;
59. Consider the three binary log files bin.00010, bin.00011, and bin.00012 from which you want to restore data. Which method would use mysqlbinlog for greater consistency?
A.
shell> mysqlbinlog bin.00010 | mysql
shell> mysqlbinlog bin.00011 | mysql
shell> mysqlbinlog bin.00012 | mysql
B. shell> mysqlbinlog bin.00010 bin.00011 bin.00012 | mysql
C. shell> mysqlbinlog –-restore bin.00010 bin.00011 bin.00012
D. shell> mysqlbinlog –-include-gtids=ALL bin.00010 bin.00011 bin.00012 | mysql
分析:
mysqlbinlog是将binlog读取并输出为文本格式的工具,输出可以直接用于mysql客户端的输入执行,这个不推荐对每个binary log进行一个一个执行。
如果执行的语句依次在不同的会话中进行,可能导致所使用的临时表的数据丢失。因此A错B正确。
C错,没有--restore这个命令项,D错,–-include-gtids应该用于指定包括一个gtid_set,没有ALL这样的用法,而且这里也没必要用这个命令项。
60. Which MySQL utility program should you to process and sort the slow Query log based on query time or average query time?
A. mysqlslow
B. mysqldumpslow
C. mysqlshow
D. mysqldump
E. mysqlaccess
分析:
The slow query log can be used to find queries that take a long time to execute and are therefore candidates for optimization.
However, examining a long slow query log can become a difficult task. To make this easier, you can process a slow query log file using the mysqldumpslow command to summarize the queries that appear in the log.
没有mysqlslow这种工具。mysqlaccess, a program to show the access rights for a user. mysqlaccess工具在MySQL 5.6中过期,并在5.7中被去除。
61. Which High Availability solution can provide a consistent, time-delayed (for example, one hour) snapshot of the live production database?
A. MySQL Replication
B. Distributed Replication Block Device
C. Windows Server Failover Clustering
D. MySQL Cluster
分析:
C错,Windows Server架构是共享存储的架构,因此直接排除。B错,DRBD是对block的I/O同步,它本身是为尽可能快的同步而使用的,并不具提供time-delayed snapshot功能。
D错,MySQL Cluster一般指的是MySQL NDB Cluster,主要提供的是高冗余,高扩展,自动分片功能,并不提供延时的snapshot。
MySQL可以通过 CHANGE MASTER TO MASTER_DELAY = N; 来调整slave库的同步延时,从而达到对主库数据作为其延时snapshot的作用。
62. You adjust a default configuration to the following /etc/my.cnf on a Linux installation:
[mysqld]
Loq-bin
Binrylog_format=ROW
You do not notice the spelling error in binrylog_format and restart your production server.
How does the MySQL server behave with incorrectly spelled options?
A. mysqld uses internal configuration versioning and reverts to the previous configuration.
B. When using mysql_config_editor for configuration adjustments, it detects incorrect syntax and typing mistakes.
C. The mysqld_safe script skips the unknown variable and starts using the remaining configuration changes.
D. mysqld prints to the error log about an unknown variable, and then exits.
分析:
我们可以将配置文件中的设置看作是mysqld服务端程序在启动时被传入的命令项设置(实际上确实是如此),因此你可以想象当你直接执行mysqld并在后面使用拼写错误的命令项时会发生什么。
B错,mysql_config_editor是对相应登陆信息做加密访问处理,相应的配置会被生成并存放在.mylogin.cnf文件中和my.cnf文件没有关系,因此使用mysql_config_editor对授权登陆信息的调整不会受到my.cnf影响。
C错,mysqld_safe调用的是mysqld,仅将这些命令项传送给mysqld,是否无视这些错误的命令项,取决于mysqld而非mysqld_safe(可直接查看MySQL bin目录下的mysqld_safe脚本以加深理解)。
64. You want to create a temporary table named OLD_INVENTORY in the OLD_INVENTORY
database on the master server. This table is not to be replicated to the slave server.
Which two changes would ensure that the temporary table does not propagate to the slave?
A. Use the –-replicate-do-db, --replicate-do-table, or --replicate-wild-do-table option with the value equal to OLD_INVENTORY.
B. Change the binlog_format option to ROW and restart mysqld before you create the OLD_INVENTORY table.
C. Stop SQL_THREAD on the slave until you have finished using the OLD_INVENTORY temporary table.
D. Set binlog_format=MIXED with the --replicate-ignore-temp-table option.
E. Use the --replicate-ignore-table option with the value equal to OLD_INENTORY.OLD_INVENTORY and restart mysqld before creating the temporary table.
分析:
A错,因为这些项指定是要复制的对象,而非被忽略复制对象。binlog_format为ROW的情况下,不会将临时表的。
C错,SQL_THREAD将relay log中的记录应用到数据库中的thread。但是相应从主库中同步过来的操作,仍然在relay log中,这和SQL_THREAD无关。
D错,无此命令项。
65. What are three facts about backups with mysqldump?
A. Can back up a remote database server
B. Allow a consistent backup to be taken
C. Are always faster to restore than binary backups
D. Are able to back up specific items within a database
E. Create automatically compressed backups
F. Will lock all storage engines for duration of backup
分析:
参考官方说明,其命令项支持远程连接,在备份操作前都要求锁表锁库,这样可以进行一致性备份。逻辑备份恢复由于需要进行逻辑数据插入操作,因此慢于binary备份恢复。
E错,导出为逻辑备份文件,并未压缩。F错,mysqldump并不会锁存储引擎,但有命令项可用于锁表锁库。
66. In a test database, you issue the SELECT … INTO OUTFILE statement to create a file with your t1 table data. You then TRUNCATE this table to empty it.
mysql> SELECT * INTO OUTFILE '/tmp/t1.sql' from t1;
mysql> TRUNCATE t1;
Which two methods will restore data to the t1 table?
A. mysql> LOAD DATA INFILE '/tmp/t1.sql' INTO TABLE t1;
B. $ mysqladmin –u root –p –h localhost test --restore /tmp/t1.sql
C. $ mysql –u root –p –h localhost test < /tmp/t1.sql
D. $ mysqlimport –u root –p –h localhost test /tmp/t1.sql
E. mysql> INSERT INTO t1 VALUES FROM '/tmp/t1.sql';
分析:
B错,无此restore命令项。C错,mysql客户端工具可以执行导入语句,但是纯数据的文本无法直接导入。E错,无法直接从外部文件获取数据进行INSERT INTO操作。
A和D都可对用于外部纯数据文件的导入。(虽然答案D在执行时,仍会有些小问题,不过从题意来讲,D可以算是正确的)
67. Which two statements are true about setting the per-thread buffers higher than required?
A. More memory per thread is beneficial in all scenarios.
B. It causes increased overhead due to initial memory allocation.
C. It can affect system stability during peak load times, due to swapping.
D. It requires increasing the thread_cache_size variable.
分析:MySQL官方并没有直接的per-thread buffer这个说法,更多的是在其它网站上的解释。不过per-thread buffer更多是指由于Connection而对应建立的Thread。
A错,这种把话说满的选择大多都不正确。
D错,thread_cache_size是指服务端应该设置用于缓存并用于重用的线程数。一般这会考虑每秒连接数和使用频繁程度有关,但其和线程buffer大小没有直接关系。
按排除法看,应该是B,C了。不过很难找到相应资料。不过可参考innodb-memory-overhead,可以了解内存page分配是涉及开销的,那因此也就不难理解per-thread buffer的开销了,B正确。
C正确,默认就分配大buffer,必然会有资源swap的问题,在高峰资源紧张的时候,swap使用,会降低查询性能,造成服务不稳定。
68. You are creating a new server with the same accounts as an existing server.
You do this by importing a mysqldump file of the mysql database.
You test whether the import was successful by using the following commands:
mysql> select user, host, password from mysql.user;
6 rows in set (0.00 sec)
mysql> show grants for 'Admin'@'%';
ERROR 1141 (42000): There is no such grant defined for user ‘admin’ on host ‘%’
Which command will fix this issue?
A. CREATE USER 'Admin'@'%';
B. GRANT USAGE ON *.* TO 'Admin'@'%';
C. FLUSH PRIVILEGES;
D. FLUSH HOST CACHE;
E. UPDATE mysql.user SET Create_user_priv = 'Y' WHERE user= 'Admin';
分析:
如果你做实验时在A机MySQL服务端建立了Admin用户。那么在A机器使用 mysql> show grants for 'Admin'@'%'; 你会看到答案B。
这表明刚建立的Admin用户没有任何权限,USAGE代表的是空权限。不过我们这里的问题是,导出数据库并导入新库后,访问新库时候的问题。
使用以下语句导出:
shell> mysqldump -uroot -p --opt --set-gtid-purged=OFF --all-database > all-db.sql
在导出的文件中,我们可以看到对于mysql.user表的数据插入。
因为你已经登陆新的MySQL服务端,然后可以使用source命令来执行all-db.sql导入操作。
完成后,实际上相应权限和用户并未被直接加载内存,因此还未起效。你需要使用FLUSH PRIVILEGES;来将倒入的用户和权限重新刷新加载到内存。
A错,从倒入文件中,可以了解,用户会被插入并建立。B错,并非授权原因。
D错,无此种命令。E错,UPDATE修改数据,不加载到内存是不起效的。
69. You are investigating the performance of the server and see the following information: Events_waits_summary_global_by_event_name in the performance schema shows that the wait/synch/mutex/sql/LOCK_table_cache event is dominating other wait events. The table_open_cache_overflows status variable is 0.
Which action should be taken to remove the performance bottleneck described here?
A. Decrease the value of table_definition_cache.
B. Increase the value of table_definition_cache.
C. Decrease the value of table_open_cache.
D. Increase the value of table_open_cache.
E. Decrease the value of table_open_cache_instances.
F. Increase the value of table_open_cache_instances.
思考:
分析题目中的提示
1. LOCK_table_cache is dominating other wait events
2. table_open_cache_overflows status variable is 0
提示1说明 table_open_cache 使用量最大
CD错,table_open_cache 没有溢出(table_open_cache / table_open_cache_instances),说明 table_open_cache 大小满足需求,去掉CD
AB错,table_definition_cache:缓存表定义(.frm)文件的数量,和 LOCK_table_cache 没什么关系。
table_open_cache_instances
A session needs to lock only one instance to access it for DML statements. This segments cache access among instances, permitting higher performance for operations that use the cache when there are many sessions accessing tables. (DDL statements still require a lock on the entire cache, but such statements are much less frequent than DML statements.)
增大 table_open_cache_instances 有利于提高会话间争用、提高扩展性。
参考:
server-system-variables
Table_open_cache_overflows
70. Which statement is true about the log-output variable?
A. It is a static variable and can be set only at MySQL server startup.
B. It enables and starts the General Query Log.
C. It sets the target location for the binary logs generated by the MySQL sever.
D. It specifies output destinations for the slow and General Query logs.
A错,因为 Dynamic = Yes
B错,General Log 是否启用是由 general_log 变量决定的
C错,Binary Log 存放位置是由 log_bin 决定的
log_output: The destination for general query log and slow query log output.
参考:
log_output
72. What is true regarding InnoDB locking?
A. InnoDB row locks may be escalated to page or table-level locks.
B. InnoDB only uses row locks, not page or table-level locks.
C. InnoDB uses row and table-level locks, but row locks are not escalates.
D. InnoDB locks only those rows that are updated.
E. InnoDB uses row-level or table-level locks depending on the number of rows affected.
首先 InnoDB 可以使用行级锁和表级锁,Intention Locks 会根据事务内容来判断是否加表级锁(当 autocommit = 0 and innodb_table_locks = 1 的时候才会执行表级锁)
D错,An exclusive (X) lock permits the transaction that holds the lock to update or delete a row.
B和E错,Intention locks are table-level locks in InnoDB that indicate which type of lock (shared or exclusive) a transaction will require later for a row in that table.
A错,The lock information in InnoDB is stored space-efficiently so that lock escalation is not needed. Typically, several users are permitted to lock every row in InnoDB tables, or any random subset of the rows, without causing InnoDB memory exhaustion.
参考:
Intention Locks
innodb_table_locks
73. Consider the MySQL Enterprise Audit plugin.On attempting to start the MySQL service after a crash, notice the following error: [ERROR] Plugin ‘audit_log’ init function returned error. In the audit log file, you notice the final entry:
What action should you take to fix the error and allow the service to start?
A. Re-install the audit plugin.
B. Execute the command FLUSH LOGS.
C. Execute the command SET GLOBAL audit_log_fiush= ON.
D. Move or rename the existing audit.log file.
参考:
Audit Log File Name
74. A general purpose MySQL instance is configured with the following options:
--slow-query-log
--long-query-time=.0001
--log-slow-admin-statements
--general-log
--log-bin
--binlog-format=STATEMENT
--innodb_flush_log_at_trx_commit=1
Which three statements are true?
A. The General Query Log records more data than the Binary Log.
B. The binary Log records more data than the General Query Log.
C. The Slow Query Log records more data than the General Query Log.
D. The General Query Log records more data than the Slow Query Log.
E. The Slow Query Log records more data than the Binary Log.
F. The Binary Log records more data than the Slow Query Log.
思考:
1. --long-query-time = .0001,--log-slow-admin-statements
上面两个变量,显示了这里的慢查询日志基本上会记录所有 DDL 和 DML
2. General Log: mysqld writes statements to the query log in the order that it receives them, which might differ from the order in which they are executed.
General Log 肯定是最多的,因为所有 mysqld 的执行都会被保存下来
3. Binary Log: The binary log contains “events” that describe database changes such as table creation operations or changes to table data
一般情况二进制日志内容会比慢查询日志多,但是在这题中显然要少于慢查询日志
4. --innodb_flush_log_at_trx_commit=1
the contents of the InnoDB log buffer are written out to the log file at each transaction commit and the log file is flushed to disk.
每次事务提交都会写入日志,并刷新到磁盘,确保了三个日志更新是同步的
General Log > Slow Query Log > Binary Log
参考:
The Binary Log
The General Query Log
The Slow Query Log
innodb_flush_log_at_trx_commit
原贴:dbdao.com MySQL OCP认证专题