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

Summary of how to use the MySQL authorization command grant

How to use the MySQL authorization command grant:...

mysql data insert, update and delete details

Table of contents 1. Insert 2. Update 3. Delete 1...

HTML table tag tutorial (13): internal border style attributes RULES

RULES can be used to control the style of the int...

MySQL DML language operation example

Additional explanation, foreign keys: Do not use ...

Detailed steps for yum configuration of nginx reverse proxy

Part.0 Background The company's intranet serv...

The iframe frame sets the white background to transparent in IE browser

Recently, I need to frequently use iframe to draw ...

Introduction to HTML_PowerNode Java Academy

What is HTML? HTML is a language used to describe...

Detailed explanation of JavaScript program loop structure

Table of contents Select Structure Loop Structure...

4 flexible Scss compilation output styles

Many people have been told how to compile from th...

How to use sed command to efficiently delete specific lines of a file

Preface Normally, if we want to delete certain li...

How to install mysql5.7 in windows

First download the compressed version of mysql, t...

Teach you how to build Tencent Cloud Server (graphic tutorial)

This article was originally written by blogger We...

jQuery plugin to achieve image comparison

This article example shares the specific code of ...

How to use JavaScript to get the most repeated characters in a string

Table of contents topic analyze Objects of use So...