cboard支持MySQL8么_[解决方案]CBoard在Mysql5.5及以下版本安装报错

在CBoard 0.4以上版本中,使用MySQL 5.5及以下版本时,在执行特定的ALTER TABLE语句添加包含DEFAULT now()的时间戳字段时会遇到报错问题。本文提供了详细的错误复现步骤,并提出了一种解决方案,即通过使用触发器来更新时间戳字段。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Please follow the below instructions to create a new system bug, otherwise, we can't help you effectively.(请严格遵循下列格式创建系统Bug主题,否则我们可能很难有效帮助到你)

What steps will reproduce the problem?(该问题的重现步骤是什么?)

CBoard 0.4以上版本, 在Mysql5.5及以下的版本安装, 执行数据库建表语句时.

即执行

"

ALTER TABLE dashboard_dataset ADD create_time TIMESTAMP DEFAULT now();

ALTER TABLE dashboard_dataset ADD update_time TIMESTAMP DEFAULT now();

ALTER TABLE dashboard_datasource ADD create_time TIMESTAMP DEFAULT now();

ALTER TABLE dashboard_datasource ADD update_time TIMESTAMP DEFAULT now();

ALTER TABLE dashboard_widget ADD create_time TIMESTAMP DEFAULT now();

ALTER TABLE dashboard_widget ADD update_time TIMESTAMP DEFAULT now();

ALTER TABLE dashboard_board ADD create_time TIMESTAMP DEFAULT now();

ALTER TABLE dashboard_board ADD update_time TIMESTAMP DEFAULT now();

"

这些语句时.

What is the expected output? What do you see instead?(你期待的结果是什么?实际看到的又是什么?)

正常应该无报错, 实际会报错..

What version of the product are you using? On what operating system?(你正在使用产品的哪个版本?在什么操作系统上?)

0.4.1, 0.4以上版本应该都会有类似的问题.

Please provide any additional information below.(如果有的话,请在下面提供更多信息。)

问题的解决有一段时间了, 没有保留错误的截图.

希望对使用低版本MySQL的同学能有些帮助.

我尝试的解决方法是:

create_time字段使用CURRENT_TIMESTAMP作为默认值.

update_time通过触发器来更新时间

CREATE TRIGGER insert_board_update_time_trigger before insert ON dashboard_board FOR EACH ROW set new.update_time = now();

CREATE TRIGGER update_board_update_time_trigger before update ON dashboard_board FOR EACH ROW set new.update_time = now();

CREATE TRIGGER insert_widget_update_time_trigger before insert ON dashboard_widget FOR EACH ROW set new.update_time = now();

CREATE TRIGGER update_widget_update_time_trigger before update ON dashboard_widget FOR EACH ROW set new.update_time = now();

CREATE TRIGGER insert_datasource_update_time_trigger before insert ON dashboard_datasource FOR EACH ROW set new.update_time = now();

CREATE TRIGGER update_datasource_update_time_trigger before update ON dashboard_datasource FOR EACH ROW set new.update_time = now();

CREATE TRIGGER insert_dataset_update_time_trigger before insert ON dashboard_dataset FOR EACH ROW set new.update_time = now();

CREATE TRIGGER update_dataset_update_time_trigger before update ON dashboard_dataset FOR EACH ROW set new.update_time = now();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值