MySQL 如何启用explicit_defaults_for_timestamp?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15701636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to enable explicit_defaults_for_timestamp?
提问by Mike Anderson
When I try to start my mySQL server I get message:
当我尝试启动 mySQL 服务器时,我收到消息:
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
[警告] 不推荐使用带有隐式 DEFAULT 值的 TIMESTAMP。
请使用 --explicit_defaults_for_timestamp 服务器选项(有关更多详细信息,请参阅文档)。
I find answer on:
http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_explicit_defaults_for_timestamp
我在以下位置找到答案:http:
//dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_explicit_defaults_for_timestamp
But how to enable it? Where?
但是如何启用它?在哪里?
回答by gagarine
First you don't need to change anything yet.
首先,您不需要更改任何内容。
Those nonstandard behaviors remain the default for TIMESTAMP but as of MySQL 5.6.6 are deprecated and this warning appears at startup
这些非标准行为仍然是 TIMESTAMP 的默认行为,但自 MySQL 5.6.6 起已弃用,并且此警告在启动时出现
Now if you want to move to new behaviorsyou have to add this line in your my.cnf
in the [mysqld] section.
现在,如果您想转向新的行为,您必须my.cnf
在 [mysqld] 部分中添加这一行。
explicit_defaults_for_timestamp = 1
The location of my.cnf (or other config files) vary from one system to another. If you can't find it refer to https://dev.mysql.com/doc/refman/5.7/en/option-files.html
my.cnf(或其他配置文件)的位置因系统而异。如果找不到,请参考https://dev.mysql.com/doc/refman/5.7/en/option-files.html
回答by Prasanna
In your mysql command line do the following:
在您的 mysql 命令行中执行以下操作:
mysql> SHOW GLOBAL VARIABLES LIKE '%timestamp%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| explicit_defaults_for_timestamp | OFF |
| log_timestamps | UTC |
+---------------------------------+-------+
2 rows in set (0.01 sec)
mysql> SET GLOBAL explicit_defaults_for_timestamp = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW GLOBAL VARIABLES LIKE '%timestamp%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| explicit_defaults_for_timestamp | ON |
| log_timestamps | UTC |
+---------------------------------+-------+
2 rows in set (0.00 sec)
回答by miyaneha
On a Windowsplatform,
在Windows平台上,
1) Find your my.iniconfiguration file.
2) In my.inigo to the [mysqld] section.
3) Add "explicit_defaults_for_timestamp" without quotes and save the change.
4) Start mysqld
1) 找到您的my.ini配置文件。
2) 在my.ini 中转到 [mysqld] 部分。
3) 添加不带引号的“explicit_defaults_for_timestamp”并保存更改。
4) 启动mysqld
This worked for me (windows 7 Ultimate 32bit)
这对我有用(windows 7 Ultimate 32bit)
回答by simon
For me it worked to add the phrase "explicit_defaults_for_timestamp = ON"without quotes into the config file my.ini
.
对我来说,它可以在配置文件中添加不带引号的短语“explicit_defaults_for_timestamp = ON”my.ini
。
Make sure you add this phrase right underneath the [mysqld] statement in the config file.
确保在配置文件中的 [mysqld] 语句正下方添加此短语。
You will find my.ini
under C:\ProgramData\MySQL\MySQL Server 5.7
if you had conducted the default installation of MySQL.
你会发现my.ini
下面C:\ProgramData\MySQL\MySQL Server 5.7
,如果你曾进行的MySQL默认安装。
回答by Andrey
On Windows you can run server with option key, no need to change ini files.
在 Windows 上,您可以使用选项键运行服务器,无需更改 ini 文件。
"C:\mysql\bin\mysqld.exe" --explicit_defaults_for_timestamp=1
"C:\mysql\bin\mysqld.exe" --explicit_defaults_for_timestamp=1
回答by akuma8
In your mysql command line: SET explicit_defaults_for_timestamp=1
在您的 mysql 命令行中: SET explicit_defaults_for_timestamp=1
回答by Vijay Nandwana
On Windows -- open my.ini file, present at "C:\ProgramData\MySQL\MySQL Server 5.6", find "[mysqld]" (without quotes) in next line add explicit_defaults_for_timestamp and then save the changes.
在 Windows 上——打开 my.ini 文件,出现在“C:\ProgramData\MySQL\MySQL Server 5.6”,在下一行找到“[mysqld]”(不带引号)添加explicit_defaults_for_timestamp,然后保存更改。
回答by BajajG
On my system (Windows 8.1), the problem was with the server configuration. The server worked for the first time when I installed it. However, I forgot to check the "run as a service" option and this caused all the problem. I tried all possible solutions available on SO but nothing worked. So, I decided to reinstall MySQL Workbench. On executing the same msi file that I earlier used to install MySQL workbench, I reconfigured the server and allowed to run the server as a service.
在我的系统(Windows 8.1)上,问题出在服务器配置上。服务器在我安装时第一次工作。但是,我忘记检查“作为服务运行”选项,这导致了所有问题。我尝试了所有可用的解决方案,但没有任何效果。所以,我决定重新安装 MySQL Workbench。在执行之前用于安装 MySQL Workbench 的相同 msi 文件时,我重新配置了服务器并允许将服务器作为服务运行。
回答by BajajG
I'm Using Windows 8.1 and I use this command
我正在使用 Windows 8.1 并且我使用此命令
c:\wamp\bin\mysql\mysql5.6.12\bin\mysql.exe
instead of
代替
c:\wamp\bin\mysql\mysql5.6.12\bin\mysqld
and it works fine..
它工作正常..