简体   繁体   English

MySQL time_zone'当前会话'-是IP还是连接?

[英]MySQL time_zone 'current session' - is it IP or Connection?

I have a project that is, intermittently, changing the time_zone value from a user defined value, to SYSTEM, and I am trying to determine if MySQL considers 'the current session' ( MySQL TimeZone ) the connection, or, the workstation IP that the connection is coming from. 我有一个项目,间歇性地将time_zone值从用户定义的值更改为SYSTEM,并且我试图确定MySQL是否将“当前会话”( MySQL TimeZone )视为连接,或者将其视为连接来自。

Basically, if it's not per connection, then something else is connecting to MySQL and changing the time_zone value back to SYSTEM, which is then having an impact on my already connected software. 基本上,如果不是每个连接都在连接,则其他连接到MySQL,并将time_zone值更改回SYSTEM,这将对我已经连接的软件产生影响。

If it is per connection, then I am back to trying to figure out WHERE the time_zone is being reset. 如果是每个连接,那么我将重新尝试找出time_zone被重置的位置。

For further info, my project is written in Delphi XE3, using the MyDAC components for DB connections. 有关更多信息,我的项目是用Delphi XE3编写的,使用MyDAC组件进行数据库连接。 When the project loads, I read a connection file and, if there is a time_zone string set, I execute the 'Set Time_zone' query. 当项目加载时,我读取了一个连接文件,并且如果设置了time_zone字符串,则执行“ Set Time_zone”查询。 The connection stays active through-out the applications run lifetime and is global to the application (ie I don't create/connect other connections from this application to the DB). 在应用程序的整个生命周期中,该连接保持活动状态,并且对于应用程序是全局的(即,我不创建/连接此应用程序与数据库之间的其他连接)。

Thanks for your assistance! 谢谢你的协助!

A MySQL session corresponds to a connection. MySQL会话对应于一个连接。

The MySQL server automatically disconnects idle sessions after a timeout, based on the value of the system variable wait_timeout , which defaults to 28800 seconds (8 hours). MySQL服务器会在超时后根据系统变量wait_timeout的值自动断开空闲会话,该值默认为28800秒(8小时)。 It sounds like Delphi is automatically reconnecting your session, but per-session settings will be lost when this happens. 听起来好像Delphi正在自动重新连接您的会话,但是这种情况下,每个会话的设置都会丢失。

You should change your application so that it sends the timezone setting if it has been idle for a long period of time. 您应该更改您的应用程序,以便在长时间闲置后发送时区设置。 You could also increase the wait_timeout (the maximum value is 2147483, 24.85 days). 您还可以增加wait_timeout (最大值为2147483,即24.85天)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM