Mysql疑难杂症收集 By Eagoo 一、可疑问题: mysql>show processlist; | 20681949 | unauthenticated user | 10.10.4.193:52497 | NULL | Connect | | Reading from net | NULL | | 20681948 | unauthenticated user | 10.10.4.193:52495 | NULL | Connect | | Reading from net | NULL | 发现有非常多的 unauthenticated user 尝试做登入使用 mysql 的情況 ,当这种情况无限制发生时就会造成系统十分缓慢。 查阅mysql官方网站得知,这属于官方一个系统上的特殊设定,就把他当成mysql的一个bug算了。不管链接的的方式是经过 hosts 或是 IP 的模式,他都会对 DNS 做反查 mysqld 会尝试去反查 IP -> DNS,由于反查解析过慢,就会无法应付过量的查询。 解决办法: /usr/local/mysql/bin/mysqld_safe --skip-name-resolve --user=mysql & 加 --skip-name-resolve 这么一个参数就可以,关闭mysql的dns反查功能。
二、Concat 乱码问题:
concat(str1,str2) 当concat结果集出现乱码时,大都是由于连接的字段类型不同导致,如concat中的字段参数一个是varchar类型,一个是int类型或doule类型,就会出现乱码。 解决方法: 利用mysql的字符串转换函数CONVERT将参数格式化为char类型就可以了。 举例: concat('数量:',CONVERT(int1,char),CONVERT(int2,char),'金额:',CONVERT(double1,char),CONVERT(double2,char))
三、UNION会出现Collection字符集不匹配的问题 解决方法;Jdbc链接使用character Encoding配置正确的字符集 跟新jdbc驱动也是必须的,有时。
四、偶尔因为断电导致mysql slave 出现复制错误“Could not parse relay log event entry” 通常的解决办法: Say a slave server runs out of disk space and the slave relay binlog is corrupt, but the master binlogs are ok (as tested with mysqlbinlog). Do I then do "show slave status /G" Master_Log_File: mysql_master-bin.000164 Read_Master_Log_Pos: 980240603 Relay_Log_File: slave2-relay-bin.000001 Relay_Log_Pos: 251111 Relay_Master_Log_File: mysql_master-bin.000164 Exec_Master_Log_Pos: 980240603 and then stop slave; and then CHANGE MASTER TO <what should go here?> ,MASTER_LOG_FILE = <Relay_Master_Log_File?> ,MASTER_LOG_POS = <Exec_Master_Log_Pos?> 例如: CHANGE MASTER TO MASTER_LOG_FILE = 'mysql_master-bin.000164',MASTER_LOG_POS =980240603; and then start slave ; show slave status /G;
五、MySQL允许用户将一个值存储为临时变量,以便后面语句使用。 变量值通过SET语句或者在SELECT语句中使用:=设置,例查看佣金大于平均值的全部SALES_REP: ======================== mysql> select @avg := AVG(commission) FROM sales_rep; +-------------------------+ | @avg := AVG(commission) | +-------------------------+ | 11.600000000 | +-------------------------+ ======================== mysql> select first_name,surname from sales_rep where commission>@avg; +------------+----------+ | first_name | surname | +------------+----------+ | So1 | Rive | | Charlene | Gordimer | +------------+----------+ ======================== 在第一个select 语句中我们:=定义了一个用户变量@avg,在第二个SELECT中我们使用了该变量。 |
本文原创自无线技术运营空间: http://wireless.qzone.qq.com 及 http://blog.csdn.net/wireless_tech (专注无线技术运营——无线技术(操作系统/数据库/WEB前端/负载均衡/系统容灾/系统安全/短信接入/WAP接入/3G等)、无线业务运营、无线开放平台、统计分析(用户行为分析/数据挖掘)、CP合作,联系我们:1780551083@qq.com)