当前位置:网站首页>Timestamp with implicit default value is deprecated error in MySQL 5.6

Timestamp with implicit default value is deprecated error in MySQL 5.6

2022-07-06 10:38:00 wx5caecf2ed0645


install MySQL when , Yes warning:

 ​?​


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101



​[[email protected] mysql]# scripts/mysql_install_db --user=mysql​

​Installing MySQL system tables...2015-08-13 14:20:09 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).​

​2015-08-13 14:20:09 0 [Note] ./bin/mysqld (mysqld 5.6.26) starting as process 1934 ...​

​2015-08-13 14:20:09 1934 [Note] InnoDB: Using mutexes to ref count buffer pool pages​

​2015-08-13 14:20:09 1934 [Note] InnoDB: The InnoDB memory heap is disabled​

​2015-08-13 14:20:09 1934 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation​

​2015-08-13 14:20:09 1934 [Note] InnoDB: Memory barrier is not used​

​2015-08-13 14:20:09 1934 [Note] InnoDB: Compressed tables use zlib 1.2.3​

​2015-08-13 14:20:09 1934 [Note] InnoDB: Using Linux native AIO​

​2015-08-13 14:20:09 1934 [Note] InnoDB: Not using CPU crc32 instructions​

​2015-08-13 14:20:09 1934 [Note] InnoDB: Initializing buffer pool, size = 128.0M​

​2015-08-13 14:20:09 1934 [Note] InnoDB: Completed initialization of buffer pool​

​2015-08-13 14:20:10 1934 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!​

​2015-08-13 14:20:10 1934 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB​

​2015-08-13 14:20:10 1934 [Note] InnoDB: Database physically writes the file full: wait...​

​2015-08-13 14:20:10 1934 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB​

​2015-08-13 14:20:11 1934 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB​

​2015-08-13 14:20:12 1934 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0​

​2015-08-13 14:20:12 1934 [Warning] InnoDB: New log files created, LSN=45781​

​2015-08-13 14:20:12 1934 [Note] InnoDB: Doublewrite buffer not found: creating new​

​2015-08-13 14:20:12 1934 [Note] InnoDB: Doublewrite buffer created​

​2015-08-13 14:20:12 1934 [Note] InnoDB: 128 rollback segment(s) are active.​

​2015-08-13 14:20:12 1934 [Warning] InnoDB: Creating foreign key constraint system tables.​

​2015-08-13 14:20:12 1934 [Note] InnoDB: Foreign key constraint system tables created​

​2015-08-13 14:20:12 1934 [Note] InnoDB: Creating tablespace and datafile system tables.​

​2015-08-13 14:20:12 1934 [Note] InnoDB: Tablespace and datafile system tables created.​

​2015-08-13 14:20:12 1934 [Note] InnoDB: Waiting for purge to start​

​2015-08-13 14:20:12 1934 [Note] InnoDB: 5.6.26 started; log sequence number 0​

​2015-08-13 14:20:14 1934 [Note] Binlog end​

​2015-08-13 14:20:14 1934 [Note] InnoDB: FTS optimize thread exiting.​

​2015-08-13 14:20:14 1934 [Note] InnoDB: Starting shutdown...​

​2015-08-13 14:20:16 1934 [Note] InnoDB: Shutdown completed; log sequence number 1625977​

​OK​


​Filling help tables...2015-08-13 14:20:16 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. ​

​Please use --explicit_defaults_for_timestamp server option (see documentation for more details).​

​2015-08-13 14:20:16 0 [Note] ./bin/mysqld (mysqld 5.6.26) starting as process 1957 ...​

​2015-08-13 14:20:16 1957 [Note] InnoDB: Using mutexes to ref count buffer pool pages​

​2015-08-13 14:20:16 1957 [Note] InnoDB: The InnoDB memory heap is disabled​

​2015-08-13 14:20:16 1957 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation​

​2015-08-13 14:20:16 1957 [Note] InnoDB: Memory barrier is not used​

​2015-08-13 14:20:16 1957 [Note] InnoDB: Compressed tables use zlib 1.2.3​

​2015-08-13 14:20:16 1957 [Note] InnoDB: Using Linux native AIO​

​2015-08-13 14:20:16 1957 [Note] InnoDB: Not using CPU crc32 instructions​

​2015-08-13 14:20:16 1957 [Note] InnoDB: Initializing buffer pool, size = 128.0M​

​2015-08-13 14:20:16 1957 [Note] InnoDB: Completed initialization of buffer pool​

​2015-08-13 14:20:16 1957 [Note] InnoDB: Highest supported file format is Barracuda.​

​2015-08-13 14:20:16 1957 [Note] InnoDB: 128 rollback segment(s) are active.​

​2015-08-13 14:20:16 1957 [Note] InnoDB: Waiting for purge to start​

​2015-08-13 14:20:16 1957 [Note] InnoDB: 5.6.26 started; log sequence number 1625977​

​2015-08-13 14:20:17 1957 [Note] Binlog end​

​2015-08-13 14:20:17 1957 [Note] InnoDB: FTS optimize thread exiting.​

​2015-08-13 14:20:17 1957 [Note] InnoDB: Starting shutdown...​

​2015-08-13 14:20:18 1957 [Note] InnoDB: Shutdown completed; log sequence number 1625987​

​OK​


​To start mysqld at boot time you have to copy​

​support-files/mysql.server to the right place for your system​


​PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !​

​To do so, start the server, then issue the following commands:​


​./bin/mysqladmin -u root password 'new-password'​

​./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'​


​Alternatively you can run:​


​./bin/mysql_secure_installation​


​which will also give you the option of removing the test​

​databases and anonymous user created by default. This is​

​strongly recommended for production servers.​


​See the manual for more instructions.​


​You can start the MySQL daemon with:​


​cd . ; ./bin/mysqld_safe &​


​You can test the MySQL daemon with mysql-test-run.pl​


​cd mysql-test ; perl mysql-test-run.pl​


​Please report any problems at ​ ​http://bugs.mysql.com/​


​The latest information about MySQL is available on the web at​


 ​http://www.mysql.com​


​Support MySQL by buying support/licenses at ​ ​http://shop.mysql.com​


​New default config file was created as ./my.cnf and​

​will be used by default by the server when you start it.​

​You may edit this file to change server settings​


​WARNING: Default config file /etc/my.cnf exists on the system​

​This file will be read by default by the MySQL server​

​If you do not want to use this, either remove it, or use the​

​--defaults-file argument to mysqld_safe when starting the server​


​[[email protected] mysql]#​


[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

The reason is from 5.6 Start ,timestamp The default behavior of is already deprecated 了 .

stay MySQL 5.6.6 Before ,TIMESTAMP Default behavior of :

•TIMESTAMP Column if not explicitly stated NULL attribute , The default is NOT NULL.( And other data types , If not, declare as NOT NULL, allows NULL value .) Set up TIMESTAMP The column value of is NULL, Will be automatically stored as the current timestamp.

• The first one in the list TIMESTAMP Column , If there is no statement NULL attribute 、DEFAULT perhaps ON UPDATE, It will be assigned automatically DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP attribute .

• The second in the table TIMESTAMP Column , If not stated as NULL perhaps DEFAULT Clause , Automatically assigned by default '0000-00-00 00:00:00′. The value of the column is not specified when the row is inserted , This column is assigned by default '0000-00-00 00:00:00′, And there's no warning .

To turn off the warning , The following parameters need to be added :

 ​?​


1

2



​[mysqld]​

​explicit_defaults_for_timestamp=true​


restart MySQL Then the error disappears , At this time TIMESTAMP Their behavior is as follows :

•TIMESTAMP If no statement is displayed NOT NULL, Is allowed NULL It's worth it , You can directly set it to NULL, There is no default fill behavior .

•TIMESTAMP No default assignment DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP attribute .

• Declare as NOT NULL And there is no default clause TIMESTAMP Columns have no default values . Insert columns into the data table , I didn't give it to TIMESTAMP When a column is assigned a value , If it's strict SQL Pattern , Will throw out a A mistake , If strictly SQL Mode is not enabled , The column is assigned to '0000-00-00 00:00:00′, There's also a warning .( This sum MySQL It's the same with other time types of data , Such as DATETIME)

( See :​ ​//www.jb51.net/article/71054.htm​​)

That is to say explicit_defaults_for_timestamp Shut down the timestamp Type field locks have some strange default behavior , After adding this parameter , If you still need to help timestamp Type specifies the default behavior , Then you need to display the specification displayed when creating the table .explicit_defaults_for_timestamp That's what it means : The display specifies that the default value is timestamp Type field .


原网站

版权声明
本文为[wx5caecf2ed0645]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131704410475.html