MYSQL5.6 OCP 1Z0-883 5.6題庫及解析一

1萄窜、A simplemaster-to-slave replication is currently being used. The following informationis extracted from the SHOW SLAVE STATUS output:?

Last_SQL_Error: Error 'Duplicate entry '8' for key 'PRIMARY'' on query. Defaultdatabase: '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 requiredbefore 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";

--------------------------------------------------------------------

答案:E

分析:此題中使用的Replication是通過GTID實現(xiàn)的恨樟,因此

A

錯拓挥,因此GLOBAL SQL_SKIP_SLAVE_COUNTER=1對使用GTID進行的Replication無效

C

錯,因為GLOBAL enforce_gtid_consistency=ON是實現(xiàn)的前提。由于GTID_NEXT的有效值為:

AUTOMATIC / ANONYMOUS / :

因此 B錯由于Retrieved_Gtid_Set:38f32e23480a7-32a1-c323f78067fd37821: 1-8

因此已經(jīng)收到主庫事務(wù)1-8瓢娜,因此報錯是從第9個事務(wù)重復(fù)記錄導(dǎo)致的醇滥,很有可能slave上的第8行被人為錄入了黎比,導(dǎo)致同步問題。

D

錯鸳玩,因為GTID_EXECUTED表示已經(jīng)執(zhí)行完成的事務(wù)阅虫。

為了臨時繞過這個問題,使用注入空事務(wù)(BEGIN; COMMIT; ) 代替完成第9個事務(wù).

完成后GTID_EXECUTED才會變?yōu)?38f32e23480a7-32a1-c323f78067fd37821: 9"

這時候重新SET GTID_NEXT="AUTOMATIC"; 重啟slave后怀喉,開始從第10個事務(wù)開始同步书妻。


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 atany time.

B.All data in p1 and p3 partitions are removed, but the table definitionremains unchanged.

C.A syntax error will result as you cannot specify more than one partition inthe same statement.

D.All data in pi and p3 partitions are removed and the table definition ischanged.

--------------------------------------------------------------------

答案:D

在刪除部分分區(qū)后,可以使用show create table查看其定義也一并改變了


3.You inherit alegacy 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') doesnot 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 WHEREDEFINER='bob@localhost';.

D.Execute SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER='bob' andHOST='localhost';.

E.Examine the Mysql error log for other ERROR 1449 messages.

----------------------------------------------------------------------------------

答案:C?

分析:routines表在庫INFORMATION_SCHEMA下躬拢,因此A錯躲履。可以登陸MySQL后聊闯,使用? show命令查看show語法工猜。可知show無routine語句菱蔬,B錯篷帅。

可使用以下命令來查看routines:

pager less;

select * from information_schema.routines\G

可知C正確

INFORMATION_SCHEMA.PROCESSLIST

表中僅顯示了當(dāng)前正在運行的線程信息,D錯。

Mysql error log

是對報錯信息的記錄拴泌,并不會有所有存儲過程的記錄魏身,E錯。


4.When designing anInnoDB 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 arealways 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

分析:關(guān)于數(shù)據(jù)類型的存儲蚪腐,可查看http://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html

A, B

都沒有特別在guide中提到箭昵。

BIT(8)

大致長度為1個Byte, 8個tinyint的存儲長度相當(dāng)于一個bigint了, 請注意并不是說tinyint(8),括號中為可顯示的長度回季,由于一個tinyint為1個Byte家制,因此8個自然要更長。因此C正確泡一。

D

錯颤殴,int類型值夜可以進行bit操作符的操作


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 eventon 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.t1table.s

B.The table definition on the slave litters from the master.

C.Multi-threaded replication slaves can have temporary errors occurring forcross database?

updates.

D.The slave SQL thread attempted to remove a row from the test.t1 table, butthe row did not


exist.

-------------------------------------------------------------------------------------------

答案:D

分析:報錯中說的非常明確Could not execute Delete_rows event on

table test.t1; Can’t find record in ‘t1’,這說明slave上這條記錄已經(jīng)被人為刪除了鼻忠,導(dǎo)致Row-Based

Replication進行同步刪除的時候涵但,找不到這條記錄。ABC選項都和此報錯以及所問問題無關(guān)。


6.mysqldump was used to create a single schemabackup;

Shell> mysqldump

–u root –p sakila> sakila2013.sql

Which two commands will restore the sakila database without interfering withother running

database?

A.Mysql> USE sakila; LOAD DATA INFILE 'sakila2013.sql';

B.Shell> mysql

–u root –psakila < 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

--------------------------------------------------------------------------------

答案:BD

分析:

A

錯贤笆,load data infile針對的是select

... into oufile輸出的表數(shù)據(jù)文件蝇棉,其文件中不含有插入執(zhí)行語句,僅含有數(shù)據(jù)芥永。而mysqldump導(dǎo)出的文件包含的數(shù)據(jù)是以可執(zhí)行sql語句實現(xiàn)的篡殷。

C

錯,因此mysqlimport是類似于load data infile語句功能的shell命令行工具埋涧,因此對應(yīng)倒入的文件都應(yīng)該是非sql語句執(zhí)行的純表數(shù)據(jù)文件板辽。我們看到mysqldump在未使用--database項導(dǎo)出時,并未在文件中使用create database語句棘催。

當(dāng)導(dǎo)入數(shù)據(jù)庫dump文件劲弦,你需要在命令中指定數(shù)據(jù)庫名,即use

db_name進入此庫:

shell> mysql db_name < dump.sql

因此B正確

mysql -e

可用于執(zhí)行語句醇坝,但是mysql客戶端語句需要使用分號作為終止符發(fā)給服務(wù)端邑跪,因此每個語句后都需要使用分號,D錯誤呼猪。

如果D為Shell> mysql –u root -p –e 'use sakila; source

sakila2013.sql;' 則正確画畅。

E

錯. mysql命令項使用中,短項使用單橫杠宋距,長命令項使用雙橫杠 -silent項應(yīng)該時候雙橫杠轴踱,因此錯。


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.logfile?

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”/>

---------------------------------------------------------

答案:A

分析:注意:MySQL Enterprise Audit是包含在MySQL企業(yè)版中的一個擴展插件谚赎,因此如果你在學(xué)習(xí)時使用的是社區(qū)版的MySQL,那你是無法實驗的淫僻。因為它需要在環(huán)境變量plugin_dir對應(yīng)目錄下存在audit_log.so插件文件。從選擇答案中可知壶唤,Audit log中使用的是舊格式進行的記錄雳灵。由于SQLTEXT僅在NAME為Query或Execute時,才會有出現(xiàn)闸盔,且NAME不存在Error狀態(tài)细办。因此B,D,E錯。而SQLTEXT僅存放所使用的SQL語句蕾殴。而返回的狀態(tài)存放在STATUS下,0為成功岛啸,非0為報錯號钓觉,因此A對C錯。


8.Which query would you use to find connectionsthat 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;

-------------------------------------------------

答案:D

分析:你可以使用 help show;命令來查看其語法可知:

SHOW [FULL] PROCESSLIST

此語法后面不可以跟where語句坚踩,因此A錯荡灾。

INFORMATION_SCHEMA.EVENTS

表顯示的是計劃的作業(yè),和連接保持的狀態(tài)時間無關(guān),B錯批幌。

INFORMATION_SCHEMA.SESSION_STATUS

表顯示的是當(dāng)前會話的變量及其變量值础锐,和狀態(tài)信息無關(guān),C錯荧缘。

INFORMATION_SCHEMA.PROCESSLIST

顯示了當(dāng)前的連接情況皆警,狀態(tài),以及狀態(tài)保持的時間截粗,實際上show processlist也是查看的這張表信姓,不過直接使用select可以使用where語句,D正確绸罗。


9.A database exists as aread-intensive server that is operating with query_cache_type =

DEMAND.

The database is refreshed periodically, but the resultset size of the queriesdoes 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 forthis has correctly

been identified as the increase in the number of concurrent users accessing theweb service.

Based solely on the information provided, what is the most likely cause forthis 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 increasedperformance


overhead due to additional memory block lookups.

C.Mutex contention on the Query Cache is forcing the queries to take longer dueto its singlethreaded nature.

D.The average resultset of a query is increasing due to an increase in thenumber of users


requiring SQL statement execution.

---------------------------------------------------------------------------------------------------------

答案:C

分析:這是一個讀密集型數(shù)據(jù)庫意推,數(shù)據(jù)庫會在一段時間后刷新,但是其查詢的結(jié)果集大小波動不大珊蟀。而所有結(jié)果集都在Query

Cache中菊值,且網(wǎng)頁應(yīng)用使用一套有限的查詢語句。且Query Cache hit rate很高育灸。因此A腻窒,D錯,請求通過的應(yīng)用查詢描扯,查詢語句數(shù)量有限定页,結(jié)果集都能放在Query Cache中,相同查詢語句的請求不會增多Query Cache中的資源的占用绽诚,因此清理查詢并非主要矛盾典徊。

B

也錯,因此Query_cache_min_res_unit設(shè)置過大恩够,僅會造成Query Cache中碎片過多卒落。如果請求的結(jié)果集都能在Query Cache中,這就和碎片沒什么關(guān)系了蜂桶。

C

正確儡毕,盡管官方文檔中未大量解釋Query Cache Mutex爭用問題,在線程運行查詢語句時扑媚,會在Query Cache中先獲取Mutex鎖腰湾,之后開始查詢匹配的查詢語句和結(jié)果集。如果找到后返回結(jié)果疆股。如果未找到匹配费坊,在執(zhí)行查詢后,需要將查詢語句和結(jié)果集插入Query Cache中旬痹,這也會需要獲取鎖附井。盡管這個時間所需非常短讨越,但是在讀密集的情況下,資源爭用會導(dǎo)致線程排隊等待現(xiàn)象永毅。


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 iscorrect 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 printedin plain text.

B.The command prints all parameters for the login-path. The password is shownonly when you?

provide the --password option.

C.The command prints all parameter for the login-path. The password is replacedwith stars.

D.The command prints the encrypted entry for the login-path. The is onlypossible to see if an


entry exists.

---------------------------------------------------

答案:C

分析:

mysql_config_editor

工具命令用于建立外部登陸文件把跨,一般由mysql客戶端或應(yīng)用來使用,好處在于登陸時免去輸入登陸密碼,密碼已經(jīng)被保存在了登陸文件中沼死。在環(huán)境變量MYSQL_TEST_LOGIN_FILE未設(shè)置的情況下着逐,mysql_config_editor默認(rèn)文件名為.mylogin.cnf,且文件保存在執(zhí)行此命令的用戶home目錄下漫雕。登陸文件建立后滨嘱,可直接使用以下命令登陸:

shell> mysql --login-path=login-path

當(dāng)然,--login-path的默認(rèn)值為client浸间,因此如果你使用mysql_config_editer set --login-path=client 來進行用戶密碼設(shè)置設(shè)置太雨,那么登陸所設(shè)用戶的時候,連--login-path也可不用了:

shell> mysql

A, D

錯魁蒜,因為不管如何囊扳,你都看不到密碼的,密碼被加密保存后兜看,使用mysql_config_editor

print會將密碼替代以星號顯示锥咸。

B

錯,使用mysql_config_editor --help可知在參數(shù)項中沒有此--password項细移,且通過參考文檔可知--password是用于設(shè)置密碼而非顯示密碼的搏予。

C

正確。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末弧轧,一起剝皮案震驚了整個濱河市雪侥,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌精绎,老刑警劉巖速缨,帶你破解...
    沈念sama閱讀 222,252評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異代乃,居然都是意外死亡旬牲,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,886評論 3 399
  • 文/潘曉璐 我一進店門搁吓,熙熙樓的掌柜王于貴愁眉苦臉地迎上來原茅,“玉大人,你說我怎么就攤上這事堕仔±揲伲” “怎么了?”我有些...
    開封第一講書人閱讀 168,814評論 0 361
  • 文/不壞的土叔 我叫張陵贮预,是天一觀的道長贝室。 經(jīng)常有香客問我,道長仿吞,這世上最難降的妖魔是什么滑频? 我笑而不...
    開封第一講書人閱讀 59,869評論 1 299
  • 正文 為了忘掉前任,我火速辦了婚禮唤冈,結(jié)果婚禮上峡迷,老公的妹妹穿的比我還像新娘。我一直安慰自己你虹,他們只是感情好绘搞,可當(dāng)我...
    茶點故事閱讀 68,888評論 6 398
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著傅物,像睡著了一般夯辖。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上董饰,一...
    開封第一講書人閱讀 52,475評論 1 312
  • 那天蒿褂,我揣著相機與錄音,去河邊找鬼卒暂。 笑死啄栓,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的也祠。 我是一名探鬼主播昙楚,決...
    沈念sama閱讀 41,010評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼诈嘿!你這毒婦竟也來了堪旧?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,924評論 0 277
  • 序言:老撾萬榮一對情侶失蹤永淌,失蹤者是張志新(化名)和其女友劉穎崎场,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體遂蛀,經(jīng)...
    沈念sama閱讀 46,469評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡谭跨,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,552評論 3 342
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了李滴。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片螃宙。...
    茶點故事閱讀 40,680評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖所坯,靈堂內(nèi)的尸體忽然破棺而出谆扎,到底是詐尸還是另有隱情,我是刑警寧澤芹助,帶...
    沈念sama閱讀 36,362評論 5 351
  • 正文 年R本政府宣布堂湖,位于F島的核電站闲先,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏无蜂。R本人自食惡果不足惜伺糠,卻給世界環(huán)境...
    茶點故事閱讀 42,037評論 3 335
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望斥季。 院中可真熱鬧训桶,春花似錦、人聲如沸酣倾。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,519評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽躁锡。三九已至午绳,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間稚铣,已是汗流浹背箱叁。 一陣腳步聲響...
    開封第一講書人閱讀 33,621評論 1 274
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留惕医,地道東北人耕漱。 一個月前我還...
    沈念sama閱讀 49,099評論 3 378
  • 正文 我出身青樓,卻偏偏與公主長得像抬伺,于是被迫代替她去往敵國和親螟够。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,691評論 2 361

推薦閱讀更多精彩內(nèi)容

  • 以前的自己淚點低峡钓,看個小說或看個綜藝節(jié)目都能把自己哭得像個小孩一樣妓笙,漸漸不知從何時起自己哭的越來越少,甚至已...
    淺沐梨書閱讀 548評論 1 6
  • 二三十年前能岩,閩南語歌曲風(fēng)靡整個閩南地區(qū)寞宫。那會兒我小舅沒別的就《初戀》。 《初戀》 擱卡懷念還是你一人 因為你是我的...
    小墉正閱讀 2,175評論 45 50
  • 1拉鹃、使用Docker的前提 必須通過dos命令行來操作Docker 2辈赋、命令的簡單嘗試 (1)、命令:docker...
    木頭amo閱讀 415評論 0 0