The MySQL server is running with the --read-only option so it cannot execute this statement
正在開會,同事電話反映開發(fā)庫不能寫入了,錯誤信息如下:
1209 - The MySQL server is running with the--read-only option so it cannot execute this statement
一般這個錯誤有兩種原因:
1.連到從庫了。從庫一般設置為只讀。
2.主庫的read_only參數(shù)被修改為1
開發(fā)人員是普通用戶應該沒有權限修改這個參數(shù)的值。
DBA也不會去主動修改這個參數(shù)。那究竟是什么原因導致開發(fā)庫不能寫入了呢?
首先確認了不是開發(fā)人員的問題,因為部門的200多位研發(fā)都遇到了這個問題。
為了先解決問題,先去查詢主庫上read_only參數(shù)的值。果然read_only被設置為1.
手工修改為0后,問題解決。問題是read_only為什么會設置為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:
由這條錯誤可知,是由于內存溢出導致了mysql的重啟
Out of memory: Kill process 12805 (mysqld)score 964 or sacrifice child
那是什么導致了內存溢出呢?
查看了系統(tǒng)的歷史命令后發(fā)現(xiàn)有同事在做備份,而此時的系統(tǒng)的壓力又比較大,且次系統(tǒng)沒有設置交換分區(qū),以上原因導致了MySQL的重啟。
Swap: 0 0 0
為什么重啟會導致read_only=1呢? 可能是配置文件中設置了read_only ,檢查配置文件
#grep read_only my.cnf
read_only = on
這時開發(fā)環(huán)境突然不能寫入的原因終于水落石出了。
你可能會問,主庫為什么設置read_only=on呢,因為原來是一個MMM環(huán)境。
現(xiàn)在已經(jīng)把MMM環(huán)境摘掉,所以將配置文件中的read_only 設置為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;(關掉新主庫的只讀屬性)
flush privileges;
2.修改mysql配置文件my.cnf,該文件在/etc目錄下
重啟mysql服務:service mysqld restart
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot exe
在安裝Mysql8.0.3過程中重置密碼時報了這個錯誤, 原因是沒有設置密碼時需要在/etc/my.cnf中添加這段時才能操作mysql
#跳過密碼驗證
skip-grant-tables
但是添加完這句后操作mysql又報了這個錯誤, 這就成了一個死循環(huán), 最后發(fā)現(xiàn)了解決辦法,
這是因為權限設置了但還沒有刷新導致的。
先執(zhí)行
flush privileges;
再執(zhí)行sql語句, 成功了
ALTER USER ’root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ’你的密碼’;
相關文章:
1. SQL Server 2005數(shù)據(jù)加密技術應用研究2. MySQL Flink Watermark實現(xiàn)事件時間處理的關鍵技術3. idea連接sql sever2019圖文教程(超詳細)4. Mysql獲取指定時間范圍數(shù)據(jù)的各種實例5. SQL Server補丁版本的檢查和安裝過程中常見問題6. MySql中 is Null段判斷無效和IFNULL()失效的解決方案7. MySQL性能壓力基準測試工具sysbench的使用簡介8. MySQL 參數(shù)相關概念及查詢更改方法9. debian10 mariadb安裝過程詳解10. Oracle如何在SQL語句中對時間操作、運算
