
问题描述
错误详情:
ERROR!The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid)
解决方案
首先排查配置文件,一般路径为:/etc/my.cnf
检查是否有多余空格、无效属性、无效字符等
如未检查出错误,将配置文件还原最初尝试启动,或者拷贝一份其他系统的配置文件。
问题描述
导入SQL文件时报错(在执行创建表或者增加字段时,发现row size长度过长,会导致出现以下错误)
[ERR] 1118 - Row size too large (> 8126). Changing some columns to TEXT or BLOB
解决方案
查看严格模式是否开启
此异常是因为数据库开启了严格模式
# 该sql语句查询数据库严格模式属性
show variables like '%innodb_strict_mode%';
执行后,innodb_strict_mode属性为ON,则代表严格模式开启,需要关闭
Variable_name Value
innodb_strict_mode ON
修改严格模式配置
# 修改MySQL配合文件,一般在/etc/my.cnf
[root@localhost ~]# vi /etc/my.cnf
# 在[mysqld]配置项下面新增一行
[mysqld]
innodb_strict_mode=0
# 保存后,重启MySQL服务
[root@localhost ~]# service mysqld restart
查看严格模式是否修改
# 登录MySQL,查询innodb_strict_mode为OFF,说明已关闭
show variables like '%innodb_strict_mode%';
问题解决
问题描述
连接报错信息如下:
java.sql.SQLException: The server time zone value ‘�й���ʱ��’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
解决方案
连接url添加时区配置
url: jdbc:mysql://localhost:3306/testuseUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
问题描述
MySQL主从库不同步1236错误:could not find first log file name in binary log index file错误是主从的一个日志问题,只要简单的配置一下即可解决。
最近造成MySQL主从库不同步问题,主要是因为电脑断了一下电,
从库日志中的错误:
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log:
‘Could not find first log file name in binary log index file’
解决方案
停止从库同步
mysql >slave stop;
主库中关闭当前的二进制日志文件并创建一个新文件,新的二进制日志文件的名字在当前的二进制文件的编号上加
mysql >flush logs;
查看主库状态,主要查看日志文件和位置:
mysql >show master status;
回到从库中,执行命令,使日志文件和位置对应主库:
mysql >CHANGE MASTER TO MASTER_LOG_FILE='log-bin.000005',MASTER_LOG_POS=107;
启动从库:
mysql >slave start;
mysql >show slave status;
状态如下,基本上是正常了,可以主库修改,测试一下从库是否同步。
Slave_IO_State: Waiting for master to send event
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
异常描述
No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
异常原因
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
The following required algorithms might be disabled: SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, include jdk.disabled.namedCurves. Edit the list of disabled algorithms to include required algorithms. You can try to enable TLSv1 or TLSv1.1 first.
JDBC driver may have disabled TLS > 1.1.
解决方案
在URL中添加在数据库后面添加
?createDatabaseIfNotExist=true&useSSL=false
如:
jdbc:mysql://192.168.2.2:3306/test?createDatabaseIfNotExist=true&useSSL=false
异常描述
ERROR 1010 (HY000): Error dropping database (can’t rmdir ‘./db_test’, errno: 39)
解决方案
直接去MySQL/MariaDB数据库目录下删掉
# rm -rf /usr/local/mysql/data/db_test
有时候目录不一样,可以直接查找目录
# 查询到数据库目录删掉就可以
find / -name db_test
默认值
group_concat 默认值 1024
属性详情
示例
累加
select group_concat(f_a) from t_one group by f_b;
按f_b进行分组查询,将每组中的f_a进行累加。
修改默认的分隔符
select group_concat(f_a separator ‘_’) from t_one group by f_b;
separator 是一个关键字,后面跟着要进行分隔的字符
排序
select group_concat(f_a order by f_a separator ‘_’) from t_one group by f_b;
修改默认字符大小
1).在MySQL配置文件中加上
group_concat_max_len = 102400 #你要的最大长度
2).可以简单一点,执行语句,可以设置作用范围
SET GLOBAL group_concat_max_len=102400;
SET SESSION group_concat_max_len=102400;
和concat使用
group_concat默认返回的是BLOB大对象,可以使用concat,返回字符串,还可以在返回的内容,在加入其它的数 据。
报错一
Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
报错二
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
因为mysql-innodb是按照page存储数据的,每个page max size是16k,然后每个page两行数据,所以每行最大8k数据。如果你的字段是blob之类的话,会存储在page之外的溢出区里。
但是innodb默认的approach(羚羊)存储格式会把每个blob字段的前864个字节存储在page里,所以你的blob超过一定数量的话,单行大小就会超过8k,所以就报错了
解决方式是使用innodb的Barracuda(梭鱼) 存储格式
这种格式对blob字段的处理方式是在page里头只存储一个20byte大小的指针,其它全存在溢出区,所以你轻易超不了8k
步骤一
打开mysql的配置my.ini。添加:max_allowed_packet=16M
步骤二
打开mysql的配置my.ini。在innodb配置出添加:innodb_file_per_table=1
步骤三
然后命令检查下上述开关是否打开。
show variables like ‘%per_table%’;
步骤四
设置mysql全局变量:innodb_file_format = Barracuda(梭鱼)
命令:set GLOBAL innodb_file_format = ‘Barracuda’;
然后检查下是否设置好了:
命令:show GLOBAL VARIABLES LIKE ‘%file_format%’;
步骤五
设置对应表的属性:ROW_FORMAT=COMPRESSED
然后检查下标的属性是否是你设置的:COMPRESSED