"Error writing to database" after upgraded to 3.7 latest

"Error writing to database" after upgraded to 3.7 latest

by hugo joe -
Number of replies: 3

I upgraded moodle from 2.6.1 to 3.7 latest.

When I tried to log in,  it failed with "Error writing to database". Then I followed the guide and did these two, but still the same error:

1.add max_allowed_packet in my.cnf. 

2. run "admin/cli/mysql_collation.php  --collation=utf8mb4_unicode_ci", but stuck in mdl_user: 

mdl_user - Error: Tried to convert mdl_user, but there was a problem. Please check the details of this table and try again.  

Now what can I do?  Edit the sql file? 

Regards.

Hugo

Average of ratings: -
In reply to hugo joe

Re: "Error writing to database" after upgraded to 3.7 latest

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Did you go t hrough the necessary upgrade steps of 2.7 and then 3.1? You can't just jump to 3.7 from 2.6. You need to restore from backup and start again...I do hope you have a back up...
In reply to Emma Richardson

Re: "Error writing to database" after upgraded to 3.7 latest

by hugo joe -
Yes, I did. I can see all the courses as visiter. Just fails to log in.
In reply to hugo joe

Re: "Error writing to database" after upgraded to 3.7 latest

by hugo joe -
This is the debug info when I try to login as user admin:
Debug info: Duplicate entry '4-admin' for key 'mdl_user_mneuse_uix'
INSERT INTO mdl_user (city,auth,username,lang,confirmed,lastip,timecreated,timemodified,mnethostid,calendartype,maildisplay,mailformat,maildigest,autosubscribe,trackforums) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
[array (
0 => '',
1 => 'manual',
2 => 'admin',
3 => 'en',
4 => 1,
5 => '192.168.154.1',
6 => 1562138322,
7 => 1562138322,
8 => '4',
9 => 'gregorian',
10 => '2',
11 => '1',
12 => '0',
13 => '1',
14 => '0',
)]
Error code: dmlwriteexception

Stack trace:
line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 1329 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1375 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
line 111 of /user/lib.php: call to mysqli_native_moodle_database->insert_record()
line 4007 of /lib/moodlelib.php: call to user_create_user()
line 4497 of /lib/moodlelib.php: call to create_user_record()
line 143 of /login/index.php: call to authenticate_user_login()