沒有實(shí)驗(yàn)過程了静檬。
ALL PRIVILEGES權(quán)限:
# 除非grant option權(quán)限,
SUPER privileges:
# 超級(jí)權(quán)限
普通用戶權(quán)限:
SELECT UPDATE INSERT ......
read_only:
When the read_only system variable is enabled,
the server permits no client updates except from users who have the SUPER privilege.
This variable is disabled by default.
FLUSH TABLE WITH READ LOCK:
鎖表,只讀陪毡,任何用戶都沒有寫入數(shù)據(jù)庫的權(quán)限诊赊。
一:mysql單機(jī)架構(gòu)
1驻售、read_only
SET GLOBAL read_only=ON
1朋贬、SUPER,ALL PRIVILEGES,root,具備修改數(shù)據(jù)庫的能力
2椭更、普通用戶則沒有,報(bào)只讀錯(cuò)誤
2谤祖、read_only + flush table with read lock
SET GLOBAL read_only=ON
flush table with read lock
1婿滓、SUPER,ALL PRIVILEGES,root,修改數(shù)據(jù)庫提交事物之后會(huì)被暫停老速。
1粥喜、要么自己退出
2、要么等解除表鎖之后繼續(xù)此事物
2橘券、普通用戶直接報(bào)只讀錯(cuò)誤
二:mysql主從復(fù)制架構(gòu)
1额湘、從數(shù)據(jù)庫read_only
單機(jī)一樣卿吐,此時(shí)的mysql 主從同步復(fù)制是可以正常進(jìn)行
2、從數(shù)據(jù)庫read_only + flush table with read lock
單機(jī)一樣锋华,此時(shí)的mysql主從同步復(fù)制是不能正常進(jìn)行嗡官。
1、從服務(wù)器可以將主服務(wù)器的二進(jìn)制日志讀取過來(日志記錄位置)
2毯焕、從服務(wù)器不能更新數(shù)據(jù)到數(shù)據(jù)庫衍腥,需要解表鎖之后才可以將數(shù)據(jù)寫入到數(shù)據(jù)庫。
1纳猫、要避免往從庫寫入數(shù)據(jù)婆咸,需要避免普通用戶賦予super & all權(quán)限。
2芜辕、flush table with read lock應(yīng)該比較常用于master鎖表尚骄,同步數(shù)據(jù)時(shí)。
3侵续、解鎖表:unlock table;