以下都是工作中使用MySQL過程中遇到的一些錯誤,特記錄之。
錯誤1:在執行mysql時 提示如下錯誤:
ERROR 1580 (HY000) at line 1: You cannot 'DROP' a log table if logging is enabled” 解決方法:執行set global slow_query_log=off,然后再次運行mysql
錯誤2:在執行innobackupex時報如下錯誤:
innobackupex: Error: Failed to connect to MySQL server: DBI connect(';mysql_read_default_file=/mvnobss/users/mysusr01/mysql/bin/my.cnf;mysql_read_default_group=xtrabackup;port=39301;
mysql_socket=/mvnobss/users/mysusr01/mysql/mydata/mysqld-hdh-vocrmdb1-39301.sock','root',...) failed: Can't connect to local MySQL server through socket '/mvnobss/users/mysusr01/mysql/mydata/mysqld-hdh-vocrmdb1-39301.sock' 解決方法:執行innobackupex備份的用戶需要對MySQL數據目錄有讀取權限,并且對socket文件有讀寫權限
錯誤3:java應用報連接異常,錯誤信息如下:
cause: com.binary.jdbc.exception.DataSourceException: Cannot create PoolableConnectionFactory (null, message from server: "Host '10.123.121.252' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'") 解決方法:mysqladmin -uroot -p flush-hosts
錯誤4:執行mysqldump報如下錯誤:
mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `res_card_storage_detail` at row: 510319
解決方法:將參數net_write_timeout的值加大(網上搜索的解決方法)
修改后問題依舊,通過觀察系統日志發現有如下重要信息: Jul 6 17:29:25 yt-votst1 kernel: Out of memory: Kill process 16398 (mysqld) score 44 or sacrifice child Jul 6 17:29:25 yt-votst1 kernel: Killed process 16398, UID 312, (mysqld) total-vm:5289288kB, anon-rss:1352100kB, file-rss:768kB 接著查看系統內存設置: free -m total used free shared buffers cached Mem: 29970 29830 139 0 169 224 -/+ buffers/cache: 29436 533 Swap: 0 0 0 結論:所以這里mysqldump報錯的真正原因是沒有設置swap導致mysqld進程內存溢出,設置swap后mysqldump運行正常。
錯誤5:mysql.user表數據被清空 解決方法:
1.在my.cnf中加入skip-grant-tables,然后重啟myqld
2.插入數據到myql.user表
mysql> insert into user(host,user,password) values('localhost','root',password('123'));
ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
3.上面報錯是因為sql_mode中有STRICT_TRANS_TABLES選項,去掉該選項然后重啟mysqld
4.執行下面的sql
mysql> insert into user(host,user,password) values('localhost','root',password('123'));
mysql> update user set select_priv='y', insert_priv='y',update_priv='y',Alter_priv='y',delete_priv='y',create_priv='y',drop_priv='y',reload_priv='y',shutdown_priv='y',Process_priv='y',file_priv='y',grant_priv='y',References_priv='y',index_priv='y',create_user_priv='y',show_db_priv='y',super_priv='y',create_tmp_table_priv='y',Lock_tables_priv='y',execute_priv='y',repl_slave_priv='y',repl_client_priv='y',create_view_priv='y',show_view_priv='y',create_routine_priv='y',alter_routine_priv='y',create_user_priv='y' where user='root';
mysql> commit;
5.去掉skip-grant-tables參數,然后重啟mysqld