MySQL入门学习之——MySQL错误解决汇总
以下都是工作中使用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
网页标题:MySQL入门学习之——MySQL错误解决汇总
链接地址:http://myzitong.com/article/gigeih.html
错误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
网页标题:MySQL入门学习之——MySQL错误解决汇总
链接地址:http://myzitong.com/article/gigeih.html