1. 程式人生 > >mysql自身報錯、java、reids連線mysql資料庫報錯彙總

mysql自身報錯、java、reids連線mysql資料庫報錯彙總

1、Can't connect to local MySQL server through socket 'tmpmysql.sock' (2)

原因是mysql根本沒有啟動

 

2、Access denied for user 'root'@'localhost' (using password YES)

解決方法:

重置密碼就行,重新執行所有授權就行

參考連線: 

https://blog.csdn.net/lisongjia123/article/details/57418989

 

 

3、com.mysql.jdbc.MysqlDataTruncation Data truncation Incorrect datetime value '0000-00-00 000000' for column

 

[[email protected] logs]# cd /usr/local/tomcat/tomcat-jenkins/logs

[[email protected] logs]# ls
catalina.2018-06-26.log catalina.out localhost.2018-06-26.log localhost_access_log.2018-06-26.txt manager.2018-06-26.log
catalina.2018-06-27.log host-manager.2018-06-26.log localhost.2018-06-27.log localhost_access_log.2018-06-27.txt


[[email protected] logs]# tail -f catalina.out

Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '0000-00-00 00:00:00' for column 'entry_time' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3833)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2535)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1911)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1203)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931)
at com.alibaba.druid.wall.WallFilter.preparedStatement_execute(WallFilter.java:602)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:131)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:45)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:73)
at org.apache.ibatis.executor.ReuseExecutor.doUpdate(ReuseExecutor.java:51)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:115)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:170)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:157)
at sun.reflect.GeneratedMethodAccessor206.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:386)

 

分析:

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

NO_ZERO_IN_DATE,NO_ZERO_DATE是無法預設為‘0000-00-00 00:00:00’的根源,去掉之後再次新建表就可以了

 

注:
NO_ZERO_IN_DATE:在嚴格模式下,不允許日期和月份為零
NO_ZERO_DATE:設定該值,mysql資料庫不允許插入零日期,插入零日期會丟擲錯誤而不是警告。

測試新建表,ok。可以了。

參考地址:

https://blog.csdn.net/zrp1992/article/details/77868305

 

4、k8s中java程式中的redis連線容器外部reids總是連線不上導致容器啟動失敗,檢視tomacat日誌得知

解決

把java程式的xml 配置檔案的reids埠 改成 6379 就可以,不要使用變數