search
HomeDatabaseMysql TutorialWhat to do if mysql datetime error occurs
What to do if mysql datetime error occursFeb 15, 2023 am 10:12 AM
mysqldatetime

Mysql datetime error solution: 1. Change datetime to timestamp timestamp; 2. Upgrade MySQL to a higher version; 3. Execute "ALTER USER 'root'@'localhost' IDENTIFIED BY 'root1' PASSWORD EXPIRE NEVER;" command is enough.

What to do if mysql datetime error occurs

The operating environment of this tutorial: Windows 10 system, MySQL version 8.0, Dell G3 computer.

What should I do if mysql datetime reports an error?

MySQL reports a datetime error when creating a table

Create the stu table in the student database and execute the following table creation statement

CREATE TABLE stu (
  id int(12) NOT NULL AUTO_INCREMENT,
  name varchar(150) CHARACTER SET utf8 DEFAULT NULL,
  age int(20),
  createTime datetime DEFAULT CURRENT_TIMESTAMP,
  updateTime datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Reports an Invalid default value for 'createTime' error , Internet Baidu said that it is only after MySQL5.6 that the datetime setting default value is supported, and then change datetime to timestamp timestamp.

When executed again, the error Incorrect table definition; there can be only oneTIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATEclause is reported. This is because current_timestamp is set for multiple timestamps.

The best solution is to upgrade MySQL to a higher version, such as 5.7 or 8.0. After I downloaded MySQL version 8.0 from the official website, the installation was completed and I used Navicat to connect to MySQL and reported a 2059 error. It is said to be caused by the inconsistent encryption rules between 8.0 and previous versions.

Use the command line to enter the MySQL interface and enter the following command

#注意:root1是连接数据库的密码,可以更改为自己想用的密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root1' PASSWORD EXPIRE NEVER; #修改数据库的加密规则 
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root1'; #更新一下localhost的密码 
FLUSH PRIVILEGES; #刷新权限

Recommended learning: "MySQL Video Tutorial"

The above is the detailed content of What to do if mysql datetime error occurs. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
如何在Python中将DateTime转换为整数?如何在Python中将DateTime转换为整数?Sep 05, 2023 pm 10:21 PM

日期和时间值的操作是编程的一个重要方面,Python语言为此提供了一个有用的内置模块,称为datetime。但是,在某些情况下,可能需要将DateTime对象转换为整数值,以便执行特定的操作或计算。在Python中将DateTime转换为整数有多种方法,每种方法都有自己的优点和缺点。在本文中,我们将深入研究这些方法并检查每种方法何时适合使用。读完本文后,您将全面了解如何在Python中有效地将DateTime对象转换为整数,并能够为您的特定编程任务选择最合适的方法。方法一:使用timestamp

使用C#中的DateTime.Today函数获取今天的日期使用C#中的DateTime.Today函数获取今天的日期Nov 18, 2023 pm 12:41 PM

使用C#中的DateTime.Today函数获取今天的日期,需要具体代码示例C#是一种面向对象的编程语言,它提供了许多内置的类和方法来处理日期和时间。其中,DateTime类具有一些非常有用的方法,例如Today属性,可以用来获得当天的日期。下面是一个示例代码,演示如何使用C#中的DateTime.Today函数获取今天的日期:usingSystem;

mysql怎么替换换行符mysql怎么替换换行符Apr 18, 2022 pm 03:14 PM

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

如何在 Python 中使用 DateTime如何在 Python 中使用 DateTimeApr 19, 2023 pm 11:55 PM

所有数据在开始时都会自动分配一个“DOB”(出生日期)。因此,在某些时候处理数据时不可避免地会遇到日期和时间数据。本教程将带您了解Python中的datetime模块以及使用一些外围库,如pandas和pytz。在Python中,任何与日期和时间有关的事情都由datetime模块处理,它将模块进一步分为5个不同的类。类只是与对象相对应的数据类型。下图总结了Python中的5个日期时间类以及常用的属性和示例。3个有用的片段1.将字符串转换为日期时间格式,也许是使用datet

MySQL复制技术之异步复制和半同步复制MySQL复制技术之异步复制和半同步复制Apr 25, 2022 pm 07:21 PM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

带你把MySQL索引吃透了带你把MySQL索引吃透了Apr 22, 2022 am 11:48 AM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。

mysql需要commit吗mysql需要commit吗Apr 27, 2022 pm 07:04 PM

在mysql中,是否需要commit取决于存储引擎:1、若是不支持事务的存储引擎,如myisam,则不需要使用commit;2、若是支持事务的存储引擎,如innodb,则需要知道事务是否自动提交,因此需要使用commit。

使用C#中的DateTime.AddDays函数给日期加上指定的天数使用C#中的DateTime.AddDays函数给日期加上指定的天数Nov 18, 2023 pm 03:08 PM

使用C#中的DateTime.AddDays函数给日期加上指定的天数在C#编程中,我们经常会遇到需要对日期进行加减运算的情况。C#中的DateTime类提供了许多方便的方法和属性来处理日期和时间,其中包括AddDays函数,它可以用来给指定的日期加上指定的天数。下面是一个具体的代码示例,演示了如何使用DateTime.AddDays函数给日期加上指定的天数:

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft