如何强制MySQL退出传统模式?
我有一个旧应用程序,从 MySQL 5.0 升级到 5.1 后开始出现故障。
一些研究表明这是由于“严格模式”导致插入某些类型的“无效”值,而这些值之前只是自动转换为合理的值。
我尝试了 SET @@SESSION.sql_mode = ''
和 SET @@GLOBAL.sql_mode = ''
但仍然收到错误。
还尝试在 my.ini
中注释掉 sql_mode
。
是否有更强大的“核”选项来解决这个问题?
I have an old application that started failing after an upgrade from MySQL 5.0 to 5.1.
A bit of research indicated this is due to "strict mode" which prevents inserting certain types of "invalid" values which previously were just automatically converted to something reasonable.
I tried SET @@SESSION.sql_mode = ''
and SET @@GLOBAL.sql_mode = ''
but I still get the error.
Also tried commenting out sql_mode
in the my.ini
.
Is there a stronger, sort of "nuclear" option to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我的应用程序中,我通常通过在每个新连接上发出命令来确保 MySQL 连接使用传统模式
。我认为如果您只是
在每个新连接上发出问题,您就会解决问题。
您应该能够通过发出命令来更改新连接的默认 SQL 模式,
但您必须使用具有足够权限的帐户来执行此操作,否则它将无法工作。
我认为,如果您想确保应用程序运行特定的 SQL 模式,最可靠的方法是为每个新连接设置它。
In my application I usually make sure that the MySQL connection is using traditional mode by issuing
on each new connection. I presume that if you just issue
on each new connection, you will have solved the problem.
You should be able to change the default SQL mode for new connections by issuing
but you must use an account with sufficient privileges to do this or it won't work.
I think that if you want to make sure a particular SQL mode is in operation for your application, the most robust way to do so is to set it for each and every new connection.
要允许无效日期,您需要:
但您最好修复您的应用程序。
To allow invalid dates, you need:
But you'd better fix your application.