mysql 8.0 一直报 SQLSTATE[HY000]: General error: 2006 MySQL server has gone away,导致数据库连接不上

laravel 部署的一个 API 应用一直提示 mysql 8.0 一直报 SQLSTATE[HY000]: General error: 2006 MySQL server has gone away,导致数据库连接不上
排查发现是,服务正在运行时,数据表添加字段时锁表了导致

-- 提现记录增加api-version
ALTER TABLE balance_cash
    ADD COLUMN	`api_version` int unsigned NOT NULL DEFAULT '0' COMMENT 'api-version',
ALGORITHM = INPLACE,
LOCK = NONE;
  • 解决方案: 重新部署 API

参考资料:https://dev.mysql.com/doc/refman/8.0/en/alter-table.html

For ALTER TABLE ... ADD, if the column has an expression default value that uses a nondeterministic function, the statement may produce a warning or error. For further information, see Section 11.6, “Data Type Default Values”, and Section 17.1.3.7, “Restrictions on Replication with GTIDs”.

重新部署API
posted @ 2022-06-30 17:06  _DongGe  阅读(1270)  评论(0编辑  收藏  举报