mysql创建错怎么结束 mysql创建表错误( 四 )


at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1379)
解决思路:针对表情插入的问题,一定还是字符集的问题 。
处理方法:我们可以直接在参数文件中 , 加入
vim /etc/my.cnf
[mysqld]
init-connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
注:utf8mb4 是 utf8 的超集 。
Top 8:使用 binlog_format=statement 这种格式 , 跨库操作,导致从库丢失数据,用户访问导致出现错误数据信息 。
当前数据库二进制日志的格式为:binlog_format=statement
在主库设置binlog-do-db=mydb1(只同步mydb1这一个库)
在主库执行use mydb2;
insert into mydb1.t1 values ('bb');这条语句不会同步到从库 。
但是这样操作就可以;
use mydb1;
insert into mydb1.t1 values ('bb');因为这是在同一个库中完成的操作 。
在生产环境中建议使用binlog的格式为row,而且慎用binlog-do-db参数 。
Top 9:MySQL 数据库连接超时的报错 ;
org.hibernate.util.JDBCExceptionReporter - SQL Error:0, SQLState: 08S01
org.hibernate.util.JDBCExceptionReporter - The last packet successfully received from the server was43200 milliseconds ago.The last packet sent successfully to the server was 43200 milliseconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection 'autoReconnect=true' to avoid this problem.
org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.JDBCConnectionException: Could not execute JDBC batch update
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
org.hibernate.util.JDBCExceptionReporter - SQL Error:0, SQLState: 08003
org.hibernate.util.JDBCExceptionReporter - No operations allowed after connection closed. Connection was implicitly closed due to underlying exception/error:
** BEGIN NESTED EXCEPTION **
大多数做 DBA 的同学,可能都会被开发人员告知,你们的数据库报了这个错误了 。赶紧看看是哪里的问题 。
这个问题是由两个参数影响的,wait_timeout 和 interactive_timeout 。数据默认的配置时间是28800(8小时)意味着,超过这个时间之后,MySQL 数据库为了节省资源,就会在数据库端断开这个连接,Mysql服务器端将其断开了,但是我们的程序再次使用这个连接时没有做任何判断 , 所以就挂了 。
解决思路:
先要了解这两个参数的特性;这两个参数必须同时设置 , 而且必须要保证值一致才可以 。
我们可以适当加大这个值,8小时太长了,不适用于生产环境 。因为一个连接长时间不工作,还占用我们的连接数,会消耗我们的系统资源 。
解决方法:
可以适当在程序中做判断;强烈建议在操作结束时更改应用程序逻辑以正确关闭连接;然后设置一个比较合理的timeout的值(根据业务情况来判断)
Top 10 :can't open file (errno:24)
有的时候,数据库跑得好好的,突然报不能打开数据库文件的错误了 。
解决思路:
首先我们要先查看数据库的 error log 。然后判断是表损坏,还是权限问题 。还有可能磁盘空间不足导致的不能正常访问表;操作系统的限制也要关注下;用 perror 工具查看具体错误!

推荐阅读