正在開會,同事電話反映開發(fā)庫不能寫入了,錯誤信息如下:
1209 - The MySQL server is running with the--read-only option so it cannot execute this statement
一般這個錯誤有兩種原因:
1.連到從庫了。從庫一般設(shè)置為只讀。
2.主庫的read_only參數(shù)被修改為1
開發(fā)人員是普通用戶應(yīng)該沒有權(quán)限修改這個參數(shù)的值。
DBA也不會去主動修改這個參數(shù)。那究竟是什么原因?qū)е麻_發(fā)庫不能寫入了呢?
首先確認了不是開發(fā)人員的問題,因為部門的200多位研發(fā)都遇到了這個問題。
為了先解決問題,先去查詢主庫上read_only參數(shù)的值。果然read_only被設(shè)置為1.
手工修改為0后,問題解決。問題是read_only為什么會設(shè)置為1呢?
解決步驟如下:
mysql> select @@read_only;
+-------------+
| @@read_only |
+-------------+
| 1 |
+-------------+
1 row in set (0.00 sec)
mysql> set global read_only=0;
Query OK, 0 rows affected (0.00 sec)
檢查mysql的錯誤日志發(fā)現(xiàn)有如下信息:
151231 13:55:11 mysqld_safe Number ofprocesses running now: 0
151231 13:55:11 mysqld_safe mysqldrestarted
由此可知MySQL發(fā)生了重啟。重啟的原因是什么呢?
檢查了系統(tǒng)日志,發(fā)現(xiàn)了如下錯誤:
#tail -100f /var/log/message
Dec 31 13:55:11 mysql2dev kernel: [8680] 500 8680 27084 92 3 0 0 bash
Dec 31 13:55:11 mysql2dev kernel: Out ofmemory: Kill process 12805 (mysqld) score 964 or sacrifice child
Dec 31 13:55:11 mysql2dev kernel: Killedprocess 12805, UID 500, (mysqld) total-vm:13146848kB, anon-rss:7870704kB,file-rss:16kB
Dec 31 13:55:11 mysql2dev kernel: rsyslogdinvoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0
Dec 31 13:55:11 mysql2dev kernel: rsyslogdcpuset=/ mems_allowed=0-1
Dec 31 13:55:11 mysql2dev kernel: Pid:21035, comm: rsyslogd Not tainted 2.6.32-358.el6.x86_64 #1
Dec 31 13:55:11 mysql2dev kernel: CallTrace:
由這條錯誤可知,是由于內(nèi)存溢出導(dǎo)致了mysql的重啟
Out of memory: Kill process 12805 (mysqld)score 964 or sacrifice child
那是什么導(dǎo)致了內(nèi)存溢出呢?
查看了系統(tǒng)的歷史命令后發(fā)現(xiàn)有同事在做備份,而此時的系統(tǒng)的壓力又比較大,且次系統(tǒng)沒有設(shè)置交換分區(qū),以上原因?qū)е铝薓ySQL的重啟。
Swap: 0 0 0
為什么重啟會導(dǎo)致read_only=1呢? 可能是配置文件中設(shè)置了read_only ,檢查配置文件
#grep read_only my.cnf
read_only = on
這時開發(fā)環(huán)境突然不能寫入的原因終于水落石出了。
你可能會問,主庫為什么設(shè)置read_only=on呢,因為原來是一個MMM環(huán)境。
現(xiàn)在已經(jīng)把MMM環(huán)境摘掉,所以將配置文件中的read_only 設(shè)置為0,至此開發(fā)庫不能寫入問題宣告解決。
MySQL報錯:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement等問題
1.登錄的mysql:mysql –u root –p
mysql> set global read_only=0;
(關(guān)掉新主庫的只讀屬性)
flush privileges;
2.修改mysql配置文件my.cnf,該文件在/etc目錄下


重啟mysql服務(wù):service mysqld restart
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot exe
在安裝Mysql8.0.3過程中重置密碼時報了這個錯誤, 原因是沒有設(shè)置密碼時需要在/etc/my.cnf中添加這段時才能操作mysql
#跳過密碼驗證
skip-grant-tables
但是添加完這句后操作mysql又報了這個錯誤, 這就成了一個死循環(huán), 最后發(fā)現(xiàn)了解決辦法,
這是因為權(quán)限設(shè)置了但還沒有刷新導(dǎo)致的。
先執(zhí)行
flush privileges;
再執(zhí)行sql語句, 成功了
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密碼';
您可能感興趣的文章:- mysql數(shù)據(jù)庫mysql: [ERROR] unknown option ''--skip-grant-tables''
- mysql視圖之確保視圖的一致性(with check option)操作詳解
- MySQL存儲表情時報錯:java.sql.SQLException: Incorrect string value:‘\xF0\x9F\x92\xA9\x0D\x0A...’的解決方法
- Mysql中的NULL和Empty String
- javascript連接mysql與php通過odbc連接任意數(shù)據(jù)庫的實例
- ubuntu下apt-get安裝和徹底卸載mysql詳解
- MySQL利用AES_ENCRYPT()與AES_DECRYPT()加解密的正確方法示例
- mysql server is running with the --skip-grant-tables option
- 利用pt-heartbeat監(jiān)控MySQL的復(fù)制延遲詳解
- MySQL pt-slave-restart工具的使用簡介