以下都是工作中使用MySQL過程中遇到的一些錯誤,特記錄之。
錯誤1:在執(zhí)行mysql時 提示如下錯誤:
ERROR 1580 (HY000) at line 1: You cannot 'DROP' a log table if logging is enabled”
解決方法:執(zhí)行set global slow_query_log=off,然后再次運(yùn)行mysql
錯誤2:在執(zhí)行innobackupex時報(bào)如下錯誤:
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'
解決方法:執(zhí)行innobackupex備份的用戶需要對MySQL數(shù)據(jù)目錄有讀取權(quán)限,并且對socket文件有讀寫權(quán)限
錯誤3:java應(yīng)用報(bào)連接異常,錯誤信息如下:
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:執(zhí)行mysqldump報(bào)如下錯誤:
mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `res_card_storage_detail` at row: 510319
解決方法:將參數(shù)net_write_timeout的值加大(網(wǎng)上搜索的解決方法)
修改后問題依舊,通過觀察系統(tǒng)日志發(fā)現(xiàn)有如下重要信息:
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
接著查看系統(tǒng)內(nèi)存設(shè)置:
free -m
total used free shared buffers cached
Mem: 29970 29830 139 0 169 224
-/+ buffers/cache: 29436 533
Swap: 0 0 0
結(jié)論:所以這里mysqldump報(bào)錯的真正原因是沒有設(shè)置swap導(dǎo)致mysqld進(jìn)程內(nèi)存溢出,設(shè)置swap后mysqldump運(yùn)行正常。
錯誤5:mysql.user表數(shù)據(jù)被清空
解決方法:
1.在my.cnf中加入skip-grant-tables,然后重啟myqld
2.插入數(shù)據(jù)到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.上面報(bào)錯是因?yàn)閟ql_mode中有STRICT_TRANS_TABLES選項(xiàng),去掉該選項(xiàng)然后重啟mysqld
4.執(zhí)行下面的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參數(shù),然后重啟mysqld
當(dāng)前標(biāo)題:MySQL入門學(xué)習(xí)之——MySQL錯誤解決匯總
新聞來源:
http://weahome.cn/article/gigeih.html