[英]How do I set SQL mode in the JDBC connection string for MySQL 8?
I recently upgraded my MySQL instance from 5.7 to 8.0.我最近将我的 MySQL 实例从 5.7 升级到了 8.0。 I connected to my old instance using JDBC and a connection string that looked like this:我使用 JDBC 和一个如下所示的连接字符串连接到我的旧实例:
jdbc:mysql://[host:port]/[database]/?sessionVariables=sql_mode=''
It seems to be a bug in MySQL Connector/J.这似乎是 MySQL Connector/J 中的一个错误。 I have raised a bug report for it:我为它提出了一个错误报告:
https://bugs.mysql.com/bug.php?id=92485 https://bugs.mysql.com/bug.php?id=92485
Try this for MySQL 8.0 in your JDBC connection string:在 JDBC 连接字符串中为 MySQL 8.0 试试这个:
jdbc:mysql://[host:port]/[database]/?sessionVariables=&&sql_mode=''
eg例如
jdbc:mysql://localhost:3306/dbName?sessionVariables=&&sql_mode=''
For MySQL 7.0 in your JDBC connection string:对于 JDBC 连接字符串中的 MySQL 7.0:
jdbc:mysql://[host:port]/[database]/?sessionVariables=sql_mode=''
eg例如
jdbc:mysql://localhost:3306/dbName?sessionVariables=sql_mode=''
我认为这可能是因为 sql_mode 中没有任何内容。
I faced the same problem with an old project and setting sessionVariables=sql_mode=''<\/code> didn't work in my case.
我在旧项目中遇到了同样的问题,设置
sessionVariables=sql_mode=''<\/code>在我的情况下不起作用。
It was totally ignored.它完全被忽略了。 Finally I found this bug report<\/a> and its explanation:最后我发现了这个错误报告<\/a>及其解释:
<\/blockquote>
"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.