Is MySQL 5.7 compatible for Moodle 3.4?

Is MySQL 5.7 compatible for Moodle 3.4?

by T K -
Number of replies: 3

Below are the server details:

Centos 7

Moodle site running on Apache, php PHP 7.0.32, mysql 5.6.40


We tried upgrading our mysql to 5.7 and faced following error:

[Thu May 23 15:48:11.475159 2019] [:error] [pid 1452] [client xx:13774] Unknown exception when starting database session : xxx - Error reading from database, referer: http://xxx

[Thu May 23 15:48:13.474616 2019] [:error] [pid 1451] [client xx:13771] Unknown exception when writing database session data : xxx - Error writing to database, referer: http://xxx

According to Moodle documentations, mysql 5.5 is minimum for Moodle 3.4, so why this error when upgraded to 5.7?

Average of ratings: -
In reply to T K

Re: Is MySQL 5.7 compatible for Moodle 3.4?

by Ken Task -
Picture of Particularly helpful Moodlers

Yes, MySQL 5.7 is compat with 3.4.

Are you using DB for sessions or files?

from moodlecode/admin/cli/

what does: php cfg.php |grep sessions

show?

a '1' would indicate site is set to save sessions to DB.  Set it to use files - less stress on any database/any version then.

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Re: Is MySQL 5.7 compatible for Moodle 3.4?

by T K -
[root@New-Moodle cli]# php cfg.php |grep sessions
dbsessions 1

Oh, so this is the issue?
Questions:
1) How can i set it to files?
2) Is the above going to affect my current moodle site?
In reply to T K

Re: Re: Re: Is MySQL 5.7 compatible for Moodle 3.4?

by Ken Task -
Picture of Particularly helpful Moodlers

From the information/error in logs you shared, looks like an issue with your DB being overloaded with trying to manage session info.

So here's some docs to look at:

https://docs.moodle.org/37/en/Session_handling
https://docs.moodle.org/37/en/Sessions_FAQ

Depending upon size of site and just how hard one wants to make admin of Moodle, try this to see if it doesn't make those errors go away in your logs:

In config.php add a line just below the line that defines 'admin', like this:

$CFG->dbsessions='0';

That turns logging sessions to the database.  Takes affect immediately.  No need to restart any services ... apache/httpd/nginx nor mysqld.

Does login speed up?   See any more errors in server logs?

Now for an admin level person ... your info about the session is larger ... thus larger sessions file.

You should see in moodledata a 'sessions' directory and as folks login, a sessions file is created for them.

To un-do ... just put // in front of that line you added.

The original question asked if MySQL 5.7 was OK to use with Moodle 3.4.   It is.

Now if you are still having issues, suggest installing and running MySQLTuner.   Could be you need to tweak DB settings.

https://www.google.com/search?q=mysqltuner

'SoS', Ken