Solve the problem when setting the date to 0000-00-00 00:00:00 in MySQL 8.0.13

Solve the problem when setting the date to 0000-00-00 00:00:00 in MySQL 8.0.13

I just started learning database operations. Today, when I was saving data, I found that an error occurred (Error 1292: Incorrect datetime value: '0000-00-00' for column 'deleted_at' at row 1) . Then I searched for the reason and found that it was because MySQL did not allow this format when storing dates. The following is a record of the process of solving the problem:

First, according to the Mysql database date, datetime type setting 0000-00-00 default value error problem this blog operation. But found out. I don't have the cnf file mentioned in the article on my computer. So I searched for the file online. Paste the contents of my.cnf into /etc/my.cnf .
But wait I will

Copy the code as follows:
sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

When pasting to the location of the file, it still fails. MySQL cannot be started directly. Later, when I set sql_mode in the command line, I saw an error message:

mysql> SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
ERROR 1231 (42000): Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'

ERROR 1231 (42000): Variable 'sql_mode' can't be set to the value of ' NO_AUTO_CREATE_USER ' means that NO_AUTO_CREATE_USER cannot be set. Then don’t set it. Then remove the sql-mode line in the my.cnf file and change the value successfully.

MySQL version: 8.0.13

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • MySQL calculates the number of days, months, and years between two dates
  • Detailed explanation of the method of comparing dates in MySQL
  • Common date comparison and calculation functions in MySQL
  • MySQL date functions and date conversion and formatting functions
  • mysql gets yesterday's date, today's date, tomorrow's date, and the time of the previous hour and the next hour
  • Detailed explanation of MySQL date string timestamp conversion
  • Detailed explanation of mysql to get the current date and format
  • MySQL date processing function example analysis

<<:  Docker installation of MySQL (8 and 5.7)

>>:  JavaScript+html to implement front-end page sliding verification

Recommend

Nginx uses reverse proxy to implement load balancing process analysis

Introduction Based on docker container and docker...

Overview of the basic components of HTML web pages

<br />The information on web pages is mainly...

A brief discussion on the characteristics of CSS float

This article introduces the characteristics of CS...

Implementation steps for building multi-page programs using Webpack

It is very common to use webpack to build single-...

Solution to PHP not being able to be parsed after nginx installation is complete

Table of contents Method 1 Method 2 After install...

Introduction to Spark and comparison with Hadoop

Table of contents 1. Spark vs. Hadoop 1.1 Disadva...

Teach you step by step to configure MySQL remote access

Preface When using the MySQL database, sometimes ...

CentOS6.9+Mysql5.7.18 source code installation detailed tutorial

CentOS6.9+Mysql5.7.18 source code installation, t...

MySQL password is correct but cannot log in locally -1045

MySQL password is correct but cannot log in local...

How to test network speed with JavaScript

Table of contents Preface Summary of the principl...

Detailed explanation of the use of DockerHub image repository

Previously, the images we used were all pulled fr...

MySQL DML statement summary

DML operations refer to operations on table recor...

MySQL detailed single table add, delete, modify and query CRUD statements

MySQL add, delete, modify and query statements 1....

How to make vue long list load quickly

Table of contents background Main content 1. Comp...

The HTML 5 draft did not become a formal standard

<br />Yesterday I saw at W3C that the new HT...