'Error writing to database' when uploading file

'Error writing to database' when uploading file

by Gerard Sargent -
Number of replies: 13

Hi everyone,

I'm stuck with a technical problem on my site and would really appreciate any help people may be able to offer.

For some reason, whenever a user tries to upload a file to a course on our Moodle, they see a message saying 'Error writing to database'. We have no idea why this started happening - only this afternoon we were uploading files without a problem. 

When I turn on Error reporting, I am told 'Cannot execute statement: impossible to write binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.' 

After digging around on the internet, it seems this may be to do with settings in /etc/my.cnf on the server. My problem is that when I try to update this file I am told I do not have the access privileges to do so.

I'm afraid this has me completely lost, and I am very worried because my users can no longer upload files to their courses. Can anyone help?

Average of ratings: -
In reply to Gerard Sargent

Re: 'Error writing to database' when uploading file

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yep - it's a MySQL setting. If you're site is hosted or you are not the system administrator of your server then you probably can't do this. You'll need to find the right person who can update that file.

In reply to Howard Miller

Re: 'Error writing to database' when uploading file

by Gerard Sargent -

Yes - the site is hosted so I’ve got in touch with the provider to find out how they can help. This has really knocked me for six - any idea why/how it happened? Everything was ticking along nicely till this evening when suddenly the error message started up. Haven’t changed any settings in the meantime. 

In reply to Gerard Sargent

Re: 'Error writing to database' when uploading file

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yeh - the setting is unsuitable for Moodle (cutting a long story short). You've got lucky up until now.

In reply to Howard Miller

Re: 'Error writing to database' when uploading file

by Gerard Sargent -

OK - thanks everyone.

Moving forward, I've been thinking I have two main options open to me at the moment.

1. The Moodle is very new and therefore only has a few courses uploaded. If I make manual backups of these, then rebuild the site from scratch using MySQL instead of MariaDB, would this help prevent the problem happening again in future?

2. Upgrade my hosting package to VPS so that I have access to such files. My service provider has given me a choice of options at https://www.ecowebhosting.co.uk/?page=vps. I'm speaking to a technician on Monday about it, but would appreciate any advice users here might have in the meantime. Do the prices look reasonable against comparable packages elsewhere? Which package do you think would be most suitable for a Moodle platform that is likely to have a maximum of around 200 visitors per month? I would imagine there will be a maximum of forty users logged in at any one time, and even this on exceptionally busy times.

In reply to Gerard Sargent

Re: 'Error writing to database' when uploading file

by James Steerpike -
As a teacher, I am paying all the costs of my Moodle for around 350 students. At times I have asked a whole class of around 60 students to log on simultaneously and peak loads some evening is maybe 10-20 students, mostly doing quizzes.
I started of with around a $2 a month hosted service and upgraded to a VPS this semester with 4G of Ram. Backups ( now small because the semester is young) run at under 30% of CPU and in class it is always under 10% CPU. The service has run without downtime for over a month now.
I am paying considerably less than the prices in  your link but I would not like to make a recommendation. I don't know how big a risk I am taking in selecting such a low cost service and I back up every night and still have my hosted service ready to go.  Support, reliability and consequences of having to rebuild Moodle and loss of student's work all have to be considered.
Average of ratings: Useful (1)
In reply to James Steerpike

Re: 'Error writing to database' when uploading file

by Gerard Sargent -

Thanks James that is really helpful. I need to make sure that the servers remain in the UK to comply with data protection, so I’ll have a look around to see what I can find. I know you are hesitant about making a recommendation, by could you point me to your providers website so I can have a look?

In reply to Gerard Sargent

Re: 'Error writing to database' when uploading file

by James Steerpike -

I have a deal at $4.99 a month but there are other options here. If you are restricted to a UK database, probably not much use.

A bit of looking showed a UK site

but again up to you.
In reply to James Steerpike

Re: 'Error writing to database' when uploading file

by Gerard Sargent -
Thanks once again, James. That is incredibly useful. The site looks interesting.
In reply to Gerard Sargent

Re: 'Error writing to database' when uploading file

by James Steerpike -

Point 1 - the MariaDb is a community-developed  fork of MySql. Seems to be standard on installs and nothing to be concerned about.

In reply to James Steerpike

Re: 'Error writing to database' when uploading file

by Gerard Sargent -

OK thanks. That's good to know and will save me a lot of wasted time trying a fresh install. I'm not quite sure why my provider says that it offers Moodle if the default db configurations prevent users from posting resources. Anyway, I'm going to shop around different providers to see what they might offer.

In reply to Gerard Sargent

Re: 'Error writing to database' when uploading file

by ben reynolds -
Skipping all the technical server talk, I'll just add that that error message on our site is most frequently associated with an emoji in a docx file that Moodle does not understand.
Average of ratings: Useful (1)
In reply to ben reynolds

Re: 'Error writing to database' when uploading file

by Fabian Glagovsky -
Picture of Particularly helpful Moodlers Picture of Testers

Exactly the same is happening in our Moodle. But hour hosting company found the solution "We would be converting your database tables from UTF8 to UTF8MB4. "

They did it on Sandbox and it fixed the problem. We are about to carry the conversion to our production site.

Best,

Fabian

In reply to Fabian Glagovsky

Re: 'Error writing to database' when uploading file

by Gerard Sargent -

Oh wow - really? I’ll try it out on a Development Moodle. Thanks very much smile