error establishing a database connection 和 Error Invalid default value for type datetime

huangapple go评论106阅读模式
英文:

error establishing a database connection and Error Invalid default value for type datetime

问题

我正面临着一个非常严重且神秘的MySQL数据库问题。有人能在最早的时候帮助我吗?

让我详细说明一下这个问题 -

这是一个在Godaddy VPS上运行的WordPress网站,使用的是php 7.4和MySQL 5.2.1版本。有一个巧合,当从constant contact电子邮件营销门户发送通讯时,这个网站就会崩溃(错误日志 - 在/wp-includes/class-wpdb.php的第2459行中出现mysqli_query(): (HY000/2006): MySQL服务器已关闭)。它在大部分时间内都能正常工作,只有在出现“连接到数据库错误”的错误时才会崩溃。
只有在我使用cpanel修复和优化数据库时才能正常工作。
我尝试了所有可能的方法,但无法找出真正的原因。

在优化数据库时出现了一些其他错误 - 请注意,表不支持优化,因此执行重新创建+分析操作
错误:'log_date_gmt'的默认值无效
状态:操作失败

我在想为什么会发生所有这些事情,而且只有在从CC门户发送通讯时才会发生,否则它的运行完全正常。我已经努力修复它很多天了,我替换了所有插件、核心文件甚至主题,但对我来说都没有用。

请帮忙拯救我。

我更新了WP核心文件、插件并优化了数据库,但对我来说都没有用。

英文:

am facing a very serious and mysterious issue with mySQL database. Could any body help me at the earliest?

Let me elaborate the issue -

Its a WordPress website running on Godaddy VPS having php 7.4 and mySQL 5.2.1 versions. There is a coincidence, when a newsletter sent from constant contact email marketing portal, this website went down (error log - mysqli_query(): (HY000/2006): MySQL server has gone away in /wp-includes/class-wpdb.php on line 2459). it works all the time and only goes down with error "connection to database error".
It works only when I repaired and optimized database using cpanel.
I tried all possible ways but not able to figure out the real cause.

Few more errors while optimizing database - Note Table does not support optimize, doing recreate + analyze instead
Error Invalid default value for 'log_date_gmt'
Status Operation failed

I am wondering why all this happens, and it only happens when newsletter sent from CC portal, otherwise it works perfectly fine. I am trying to fix it for many days, I replace all plugins, core files and even theme but nothing work for me.

Please help and save me.

I updated WP core files, plugins and optimized database but nothing work for me..

答案1

得分: 1

"Table does not support optimize, doing recreate + analyze instead" 是正常的。OPTIMIZE TABLE xxx 函数是针对旧版的 MyISAM 访问方式在 MySQL 中的,当你对一个 InnoDB 表执行它时,就会发出这个警告。一切都正常运行。

"Error Invalid default value for 'log_date_gmt'" 发生是因为 WordPress 的数据库设计中有许多 DATETIME 列,其默认值为 0000-00-00 00:00:00。需要设置你的 SQL 模式以允许零日期操作 WordPress 表。

WordPress 每次连接到 MySQL 时都会发出以下命令,它会更新 sql_mode。在重新构建 WordPress 表之类的操作之前,你可以发出相同的命令,这样 "invalid default value" 错误就会停止。

SET @@sql_mode := REPLACE(@@sql_mode, 'NO_ZERO_DATE', '');

至于 MySQL 服务器因某种方式(令人费解???)由电子邮件群发引起的崩溃,我会怀疑是 RAM 或 HDD / SSD 硬盘空间耗尽。查看服务器机器上的日志,尝试找出发生了什么。通常情况下,日志会非常清晰。或者,可以请求 GoDaddy 技术支持来处理。如果你的网站发展壮大,可能需要迁移到更具能力的托管设置。

英文:

Table does not support optimize, doing recreate + analyze instead is normal. The OPTIMIZE TABLE xxx function was specific to the older MyISAM access method in MySQL, and this warning gets issued when you do it to an InnoDB table. Everything works correctly.

Error Invalid default value for 'log_date_gmt' happens because WordPress's database design has many DATETIME columns with default values of 0000-00-00 00:00:00. It's necessary to set your sql mode to allow zero dates to operate on WordPress tables.

WordPress issues the following command whenever it connects to MySQL. It updates sql_mode. You can issue the same command before doing anything like rebuilding WordPress tables, and the *invalid default value" errors will stop.

SET @@sql_mode := REPLACE(@@sql_mode, 'NO_ZERO_DATE', '');

As for the MySQL server crash caused somehow (wtf???) by an email blast, I would suspect RAM or HDD / SSD drive space ran out. Look at the logs on the server machine and try to figure out what happened. They are usually quite clear. Or, ask GoDaddy tech support to do it. You may need to migrate to a more capable hosting setup, especially if your site has grown a lot.

huangapple
  • 本文由 发表于 2023年8月10日 23:16:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76877121.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定