设为首页 加入收藏

TOP

MySQL使用过程中的报错处理(持续更新)
2019-09-17 18:49:52 】 浏览:29
Tags:MySQL 使用 过程 处理 持续 更新

一、数据库初始化

1、Percona的MySQL 5.6.20版本数据库初始化

初始化命令(MySQL 5.6版本不适用mysqld命令进行初始化)

./scripts/mysql_install_db --defaults-file=/opt/app/mysql/my.cnf --user=mysql --basedir=/opt/app/mysql --datadir=/opt/app/mysql/data 
报错信息如下:
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
解决方法是安装autoconf库
执行命令:yum -y install autoconf 安装成功后继续执行初始化命令

 

二、MySQL使用问题处理

1、关于function的报错

#数据库中使用函数报错如下
ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable 如果我们开启了 bin-log, 我们就必须为我们的function指定一个参数 解决办法: set @@global.log_bin_trust_function_creators = 1;

2、字段长度过长导致的索引长度超出限制错误

#导入数据报错如下
ERROR 1071 (42000) at line 32131: Specified key was too long; max key length is 767 bytes #解决办法:
set @@global.innodb_large_prefix = ON
#上述问题如果还存在则调节如下参数 ERROR
1709 (HY000) at line 32131: Index column size too large. The maximum column size is 767 bytes. set @@global.innodb_file_format_max = Barracuda; //默认的值为Antelope set @@global.innodb_file_format = Barracuda ;

 

3、sysbench压力测试MySQL的QPS&&TPS报错

#使用sysbench压力测试调节threads参数为100时,报错如下
FATAL: `thread_init' function failed: /usr/share/sysbench/oltp_common.lua:284: SQL API error
FATAL: MySQL error: 1461 "Can't create more than max_prepared_stmt_count statements (current value: 16382)"
(last message repeated 3 times)

#解决办法
在使用sysbench压力测试的时候 并发线程达到100的时候报错,max_prepared_stmt_count参数限制了同一时间在mysqld上所有会话中的prepare语句的上限,它的取值范围为“0--1048576”,默认值为16382,超出这个值的prepare语句会报1461错误
set global max_prepared_stmt_count=1048576; //不建议调节,线程数给到16或者32就可以满足压力测试提供参考依据的目的

 

4、数据库服务启动问题

#数据库服务start|stop|restart命令一直卡住,没有输出执行结果,通过status查看到有如下进程,尝试kill该进程失败
/bin/bash /usr/bin/mysql-systemd-start post

#解决办法
通过错误日志分析找到ERROR级别的日志,分析错误点数据目录无法写入,更改数据目录的属主属组为mysql,重启服务恢复正常

 

5、delete使用子查询问题

delete from suser where id in (select id from user where user_id = 73539);
You can't specify target table 'sc_sys_user_weixin' for update in FROM clause

#解决办法
将SELECT出的结果再通过中间表SELECT一遍,这样就规避了错误

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇浅谈基于Linux的Redis环境搭建 下一篇mysql命令框中向表中插入中文字符..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目