MySQL之time zone,附带MySQL调试日志

应用程序连接MySQL时,无法识别time zone,报错信息如下:
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.

配置MySQL数据库的time zone

查询数据库当前的time zone

mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone |        |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set

在my.ini添加default-time-zone,这里设置成东八区

default-time-zone = '+8:00'
mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone |        |
| time_zone        | +08:00 |
+------------------+--------+
2 rows in set

如果配置错误,报如下信息

[ERROR] Fatal error: Illegal or unknown default time zone 'timezone'

配置应用程序的数据库URL

url: jdbc:mysql://localhost:3306/abc?createDatabaseIfNotExist=true&characterEncoding=utf-8serverTimezone=UTC

MySQL错误调试

当调试MySQL时,通过命令行或者服务启动时,无法定位问题,需要通过日志输出查找问题,MySQL的日志说明详见官方文档

级别名称描述
1-log-error错误日志记录发生错误的事件
2- log查询日志记录所有的查询语句
3-slow_query_log慢查询日志记录所有查询时间慢于某个值(long_query_time)的查询事件
4-log_bin二进制日志记录所有更新和删除的语句,用于恢复到崩溃前数据库
#log-error
log-error=D:/mysql-5.6.49-winx64/log/err.log

#log
log_output=FILE     
general_log=on
general_log_file=D:/mysql-5.6.49-winx64/log/query.log

#slow_query_log
slow_query_log=on   
long_query_time =2  
slow_query_log_file=D:/mysql-5.6.49-winx64/log/slowquery.log

#log_bin 
server-id=1
log_bin=D:/mysql-5.6.49-winx64/log/binlog-bin
log_bin_index=D:/mysql-5.6.49-winx64/log/binlog
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值