迁移Moodle至独立服务器时遇MariaDB 'id'字段无默认值错误求助
环境信息
- Moodle版本:v4.1.4
- PHP版本:8.1
- 数据库:MariaDB 15.1(Debian系统,搭配Froxlor面板)
问题详情
将Moodle从虚拟主机迁移至独立服务器,已完成以下操作:
- 迁移所有文件至新服务器
- 导入原数据库到新服务器的MariaDB
- 更新
config.php配置文件以匹配新环境
完成后访问站点,出现数据库写入错误,具体错误信息如下:
Error writing to database
Debug info: Field 'id' doesn't have a default value
INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip) VALUES(?,?,?,?,?,?,?,?)
[array (
0 => 0,
1 => 'om9er1b27to3rqt5broqcknooi',
2 => NULL,
3 => 0,
4 => 1709207762,
5 => 1709207762,
6 => '95.90.242.199',
7 => '95.90.242.199',
)]
Error code: dmlwriteexception
Stack trace:
line 497 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
line 1362 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
line 1408 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
line 573 of /lib/classes/session/manager.php: call to mysqli_native_moodle_database->insert_record()
line 550 of /lib/classes/session/manager.php: call to core\session\manager::add_session_record()
line 165 of /lib/classes/session/manager.php: call to core\session\manager::initialise_user_session()
line 139 of /lib/classes/session/manager.php: call to core\session\manager::start_session()
line 842 of /lib/setup.php: call to core\session\manager::start()
line 33 of /config.php: call to require_once()
line 30 of /index.php: call to require_once()
已尝试长时间搜索解决方案但未找到有效方法,恳请各位提供帮助!
内容的提问来源于stack exchange,提问作者Dominik

