国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

MySQL 5.6 中TIMESTAMP with implicit DEFAULT value is deprecated錯誤

2024-07-24 13:07:50
字體:
來源:轉載
供稿:網友

安裝mysql的時候出現TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details),可以參考下面的方法解決

安裝MySQL時,有warning:

 

 
  1. [root@localhost mysql]# scripts/mysql_install_db --user=mysql 
  2. 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). 
  3. 2015-08-13 14:20:09 0 [Note] ./bin/mysqld (mysqld 5.6.26) starting as process 1934 ... 
  4. 2015-08-13 14:20:09 1934 [Note] InnoDB: Using mutexes to ref count buffer pool pages 
  5. 2015-08-13 14:20:09 1934 [Note] InnoDB: The InnoDB memory heap is disabled 
  6. 2015-08-13 14:20:09 1934 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation 
  7. 2015-08-13 14:20:09 1934 [Note] InnoDB: Memory barrier is not used 
  8. 2015-08-13 14:20:09 1934 [Note] InnoDB: Compressed tables use zlib 1.2.3 
  9. 2015-08-13 14:20:09 1934 [Note] InnoDB: Using Linux native AIO 
  10. 2015-08-13 14:20:09 1934 [Note] InnoDB: Not using CPU crc32 instructions 
  11. 2015-08-13 14:20:09 1934 [Note] InnoDB: Initializing buffer pool, size = 128.0M 
  12. 2015-08-13 14:20:09 1934 [Note] InnoDB: Completed initialization of buffer pool 
  13. 2015-08-13 14:20:10 1934 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created! 
  14. 2015-08-13 14:20:10 1934 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB 
  15. 2015-08-13 14:20:10 1934 [Note] InnoDB: Database physically writes the file full: wait... 
  16. 2015-08-13 14:20:10 1934 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB 
  17. 2015-08-13 14:20:11 1934 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB 
  18. 2015-08-13 14:20:12 1934 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 
  19. 2015-08-13 14:20:12 1934 [Warning] InnoDB: New log files created, LSN=45781 
  20. 2015-08-13 14:20:12 1934 [Note] InnoDB: Doublewrite buffer not found: creating new 
  21. 2015-08-13 14:20:12 1934 [Note] InnoDB: Doublewrite buffer created 
  22. 2015-08-13 14:20:12 1934 [Note] InnoDB: 128 rollback segment(s) are active. 
  23. 2015-08-13 14:20:12 1934 [Warning] InnoDB: Creating foreign key constraint system tables. 
  24. 2015-08-13 14:20:12 1934 [Note] InnoDB: Foreign key constraint system tables created 
  25. 2015-08-13 14:20:12 1934 [Note] InnoDB: Creating tablespace and datafile system tables. 
  26. 2015-08-13 14:20:12 1934 [Note] InnoDB: Tablespace and datafile system tables created. 
  27. 2015-08-13 14:20:12 1934 [Note] InnoDB: Waiting for purge to start 
  28. 2015-08-13 14:20:12 1934 [Note] InnoDB: 5.6.26 started; log sequence number 0 
  29. 2015-08-13 14:20:14 1934 [Note] Binlog end 
  30. 2015-08-13 14:20:14 1934 [Note] InnoDB: FTS optimize thread exiting. 
  31. 2015-08-13 14:20:14 1934 [Note] InnoDB: Starting shutdown... 
  32. 2015-08-13 14:20:16 1934 [Note] InnoDB: Shutdown completed; log sequence number 1625977 
  33. OK 
  34.  
  35. Filling help tables...2015-08-13 14:20:16 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.  
  36. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 
  37. 2015-08-13 14:20:16 0 [Note] ./bin/mysqld (mysqld 5.6.26) starting as process 1957 ... 
  38. 2015-08-13 14:20:16 1957 [Note] InnoDB: Using mutexes to ref count buffer pool pages 
  39. 2015-08-13 14:20:16 1957 [Note] InnoDB: The InnoDB memory heap is disabled 
  40. 2015-08-13 14:20:16 1957 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation 
  41. 2015-08-13 14:20:16 1957 [Note] InnoDB: Memory barrier is not used 
  42. 2015-08-13 14:20:16 1957 [Note] InnoDB: Compressed tables use zlib 1.2.3 
  43. 2015-08-13 14:20:16 1957 [Note] InnoDB: Using Linux native AIO 
  44. 2015-08-13 14:20:16 1957 [Note] InnoDB: Not using CPU crc32 instructions 
  45. 2015-08-13 14:20:16 1957 [Note] InnoDB: Initializing buffer pool, size = 128.0M 
  46. 2015-08-13 14:20:16 1957 [Note] InnoDB: Completed initialization of buffer pool 
  47. 2015-08-13 14:20:16 1957 [Note] InnoDB: Highest supported file format is Barracuda. 
  48. 2015-08-13 14:20:16 1957 [Note] InnoDB: 128 rollback segment(s) are active. 
  49. 2015-08-13 14:20:16 1957 [Note] InnoDB: Waiting for purge to start 
  50. 2015-08-13 14:20:16 1957 [Note] InnoDB: 5.6.26 started; log sequence number 1625977 
  51. 2015-08-13 14:20:17 1957 [Note] Binlog end 
  52. 2015-08-13 14:20:17 1957 [Note] InnoDB: FTS optimize thread exiting. 
  53. 2015-08-13 14:20:17 1957 [Note] InnoDB: Starting shutdown... 
  54. 2015-08-13 14:20:18 1957 [Note] InnoDB: Shutdown completed; log sequence number 1625987 
  55. OK 
  56.  
  57. To start mysqld at boot time you have to copy 
  58. support-files/mysql.server to the right place for your system 
  59.  
  60. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! 
  61. To do so, start the server, then issue the following commands: 
  62.  
  63. ./bin/mysqladmin -u root password 'new-password' 
  64. ./bin/mysqladmin -u root -h localhost.localdomain password 'new-password' 
  65.  
  66. Alternatively you can run: 
  67.  
  68. ./bin/mysql_secure_installation 
  69.  
  70. which will also give you the option of removing the test 
  71. databases and anonymous user created by default. This is 
  72. strongly recommended for production servers. 
  73.  
  74. See the manual for more instructions. 
  75.  
  76. You can start the MySQL daemon with
  77.  
  78. cd . ; ./bin/mysqld_safe & 
  79.  
  80. You can test the MySQL daemon with mysql-test-run.pl 
  81.  
  82. cd mysql-test ; perl mysql-test-run.pl 
  83.  
  84. Please report any problems at http://bugs.mysql.com/ 
  85.  
  86. The latest information about MySQL is available on the web at 
  87.  
  88. http://www.mysql.com 
  89.  
  90. Support MySQL by buying support/licenses at http://shop.mysql.com 
  91.  
  92. New default config file was created as ./my.cnf and 
  93. will be used by default by the server when you start it. 
  94. You may edit this file to change server settings 
  95.  
  96. WARNING: Default config file /etc/my.cnf exists on the system 
  97. This file will be read by default by the MySQL server 
  98. If you do not want to use this, either remove it, or use the 
  99. --defaults-file argument to mysqld_safe when starting the server 
  100.  
  101. [root@localhost mysql]# 

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

其原因是從 5.6開始,timestamp 的默認行為已經是 deprecated 了。

在MySQL 5.6.6之前,TIMESTAMP的默認行為:

•TIMESTAMP列如果沒有明確聲明NULL屬性,默認為NOT NULL。(而其他數據類型,如果沒有顯示聲明為NOT NULL,則允許NULL值。)設置TIMESTAMP的列值為NULL,會自動存儲為當前timestamp。

•表中的第一個TIMESTAMP列,如果沒有聲明NULL屬性、DEFAULT或者 ON UPDATE,會自動分配 DEFAULT CURRENT_TIMESTAMP和ON UPDATE CURRENT_TIMESTAMP 屬性。

•表中第二個TIMESTAMP列,如果沒有聲明為NULL或者DEFAULT子句,默認自動分配'0000-00-00 00:00:00′。插入行時沒有指明改列的值,該列默認分配'0000-00-00 00:00:00′,且沒有警告。

要關閉警告,需要加入下面的參數:

 

 
  1. [mysqld] 
  2. explicit_defaults_for_timestamp=true 

重啟MySQL后錯誤消失,這時TIMESTAMP的行為如下:

•TIMESTAMP如果沒有顯示聲明NOT NULL,是允許NULL值的,可以直接設置改列為NULL,而沒有默認填充行為。

•TIMESTAMP不會默認分配DEFAULT CURRENT_TIMESTAMP 和 ON UPDATE CURRENT_TIMESTAMP屬性。

•聲明為NOT NULL且沒有默認子句的TIMESTAMP列是沒有默認值的。往數據表中插入列,又沒有給TIMESTAMP列賦值時,如果是嚴格SQL模式,會拋出一 個錯誤,如果嚴格SQL模式沒有啟用,該列會賦值為'0000-00-00 00:00:00′,同時出現一個警告。(這和MySQL處理其他時間類型數據一樣,如DATETIME)

也就是 explicit_defaults_for_timestamp 關閉了 timestamp 類型字段鎖擁有的一些會讓人感到奇怪的默認行為,加入了該參數之后,如果還需要為 timestamp類型的字段指定默認行為,那么就需要顯示的在創建表時顯示的指定。explicit_defaults_for_timestamp 也就是這個意思:顯示指定默認值為timestamp類型的字段。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 华容县| 保山市| 龙川县| 岳阳市| 新乡县| 内黄县| 屏东市| 洪雅县| 安国市| 松原市| 修武县| 甘孜| 石家庄市| 孟州市| 苗栗县| 弥渡县| 剑阁县| 射洪县| 恩施市| 茂名市| 丹棱县| 繁峙县| 筠连县| 梓潼县| 响水县| 平定县| 济阳县| 亳州市| 体育| 建水县| 安义县| 剑川县| 宜宾市| 安岳县| 出国| 寿光市| 九龙城区| 大英县| 玛纳斯县| 桦川县| 新和县|