PythonAnywhere Forums

Using MySQL 5.7

Hi, I've built a Django webapp that I'm trying to deploy. I have a MySQL db that I'm trying to populate with

LOAD DATA LOCAL INFILE...

to grab data from .csv files. This works locally, but on the server it gives the error:

django.db.utils.OperationalError: (1148, 'The used command is not allowed with this MySQL version')

I assume that this is because my local version of MySQL is different to PA's. Locally I've been using MySQL 5.7, but it seems PA runs MySQL 5.6.

So my question is, is there anyway to either use MySQL 5.7 on PA, or get the 'LOAD DATA LOCAL INFILE command working on on 5.6? I've seen solutions that involve editing the my.cnf file, but as far as I'm aware, you guys don't allow that.

Hi there,

I'm not sure about the permissions stuff, but you should have a .my.cnf in your homedir. See if that works?

Oh my mistake, I'd read an old forum post that mentioned you didn't allow access to the my.cnf file, but that seems to have changed now. Thanks for the advice. I edited the my.cnf file so it reads:

[mysql] local-infile = 1

[client] loose-local-infile=1

as suggested in this article but still no luck. It also mentioned that restarting the mysql service might be necessary, but I can't run:

$ sudo service mysql restart

from a console (which is fair enough, since I don't have root privileges). I thought the mysql service might also restart if I reloaded my webapp, so I tried that as well, but it still loading the csv still gives the same error. Is there a way to restart the mysql service? Or, could you confirm if it is restarted when I reload the webapp, so that I know my changes to the my.cnf file had no effect?

Thanks,

Sam

Hmm. Reading this, it seems like LOCAL is a security concern, so it is probably disabled. Also, according to the article, the error you are seeing means that we have disabled it.

It also proposes to use ssl-mode as a way around this- maybe try that?

Restarting your webapp will not restart mysql, and you won't be able to do that.

Thanks for the response. Sorry maybe I'm not understanding. From the documentation on ssl-mode you linked, it looked like it's a flag to start the mysql client with from a terminal. Something like:

$ mysql --ssl-mode

But I was under the impression that the only way to start the client was by clicking the link next to 'Start a console on:' in the Databases tab of my profile page. Is there a way to start the mysql client from a bash console? or maybe it's possible to set the flags I plan to use somewhere?

yup- see the help pages on this

Ahh awesome. Thanks for that. Strangely enough, when running mysql from the terminal (even without the --ssl-mode, or --local-infile flags), I get no errors whatsoever and all my data imported correctly. So problem solved I guess, even if I'm not sure how exactly it was fixed.

Thanks for the help and suggestions.

Sam