mysql 解决时间格式不对的问题
Error 1292: Incorrect datetime value: '0000-00-00' for column 'update_t
Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
解决方案一:
# 修改全局
set @@global.sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
# 修改当前
set @@sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
参考文章:1292 - Incorrect datetime value: '0000-00-00 00:00:00' for column - lewisat - 博客园
https://blog.csdn.net/bluewelkin/article/details/106624997
修改完之后,不需要重启myslq。但是需要重启应用服务器。因为之前还建立了连接。
-------------------------------------------------------------------------------------------
解决方案二:
上面方案可行,但是一旦重启电脑,内存中的值又丢失了配置的选项。
根本性解决:
1、在Mac OS X 中默认是没有my.cnf 文件。故
在终端输入cd /etc,进入/etc文件夹下,然后在/etc新建my.cnf文件,使用命令:sudo vim my.cnf
2、配置文件里输入内容
[client]
default-character-set=utf8
#password = your_password
port = 3306
socket = /tmp/mysql.sock
[mysqld]
character-set-server=utf8
init_connect='SET NAMES utf8
port =3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
character-set-server=utf8
init_connect='SET NAMES utf8'
#skip-networking
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
# server-id = 2
# The replication master for this slave - required
#master-host =
# The username the slave will use for authentication when connecting
# to the master - required
#master-user =
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =
# The port the master is listening on.
# optional - defaults to 3306
#master-port =
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/mysql/data
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/data
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
default-character-set=utf8
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
3、wq! 保存之后
4、sudo chmod 664 /etc/my.cnf
5、在【mysqld】字段 的 下方新增
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
6、重启mysql即可
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
