+ -
当前位置:首页 → 问答吧 → SET Date_Format = '%d/%m/%y'; 运行以后报告错误

SET Date_Format = '%d/%m/%y'; 运行以后报告错误

时间:2011-07-18

来源:互联网

已有MS SQL Server的脚本,里面的日期格式是DMY的。想修改下直接拿来给MySQL用。

在MySQL中尝试修改系统变量 Date_Format,
SET Date_Format = '%d/%m/%y';

运行以后报告错误:
Error Code: 1238. Variable 'date_format' is a read only variable.
Date_Format 和 Datetime_Format都不让修改。

试验了下其他的系统变量,
SET GLOBAL connect_timeout = 10;
成功了,但Date_format 设置就报 read only,为什么?

有没有人能解答下啊?谢谢!

作者: Sieg1978   发布时间: 2011-07-18

在mysql的配置文件my.cnf 或者 my.ini中 加入  
[mysqld]
date_format= %Y/%m/%d
datetime_format=%Y/%m/%d %H:%i:%s
最后mysql服务器重启即可。

作者: wwwwb   发布时间: 2011-07-18