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

How to implement responsive layout with CSS

Implementing responsive layout with CSS Responsiv...

Detailed explanation of Vue's simple store

The simplest application of store in Vue is globa...

JavaScript to achieve product magnifying glass effect

This article shares the specific code of JavaScri...

Three ways to parse QR codes using javascript

Table of contents 1. Use JavaScript to parse the ...

VMWare15 installs Mac OS system (graphic tutorial)

Installation Environment WIN10 VMware Workstation...

How to configure redis sentinel mode in Docker (on multiple servers)

Table of contents Preface condition Install Docke...

Talking about Less and More in Web Design (Picture)

Less is More is a catchphrase for many designers....

Vue implements a small weather forecast application

This is a website I imitated when I was self-stud...

How to smoothly upgrade nginx after compiling and installing nginx

After nginx is compiled and installed and used fo...

JavaScript to achieve simple tab bar switching case

This article shares the specific code for JavaScr...

Causes and solutions for MySQL deadlock

The database, like the operating system, is a sha...

Solve the problem of PhPStudy MySQL startup failure under Windows system

Report an error The Apache\Nginx service started ...