Upgrade Mysql

47 views
Skip to first unread message

Dariusz Mysior

unread,
Jun 20, 2014, 11:31:10 AM6/20/14
to django...@googlegroups.com
I use pythonanywhere.com Django 1.6 and Python 2.7 I

and when I write p.save() I had error like below.

It says something about updating mysql to fix it, but I don't know what code or shell commands I need to write.

Can you help me? One person post that he upgrade MySQL to 5.0.27 but I don't know what is a commend for do this :/.....

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py", line 545, in save
    force_update=force_update, update_fields=update_fields)
  File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py", line 570, in save_base
    with transaction.commit_on_success_unless_managed(using=using, savepoint=False):
  File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/transaction.py", line 280, in __enter__
    connection.set_autocommit(False)
  File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 340, in set_autocommit
    self._set_autocommit(autocommit)
  File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 461, in _set_autocommit
    self.connection.autocommit(autocommit)
  File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 461, in _set_autocommit
    self.connection.autocommit(autocommit)
  File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 243, in autocommit
    _mysql.connection.autocommit(self, on)
OperationalError: (2006, 'MySQL server has gone away')

François Schiettecatte

unread,
Jun 20, 2014, 11:40:58 AM6/20/14
to django...@googlegroups.com
Dariusz

Not sure about upgrading mysql, what the error is telling you is that mysql is dropping the connection before django is done with it.

I would look at CONN_MAX_AGE in DATABASES (in settings.py) and wait_timeout in my.cnf, the first should be lower than the second.

For example I have these settings for a project:

'CONN_MAX_AGE': 3500, # 3500 seconds because wait_timeout = 3600 in my.cnf


Cheers

François
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0dc3a793-2fd0-4884-87f3-b14724bdd1ab%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Dariusz Mysior

unread,
Jun 20, 2014, 12:04:06 PM6/20/14
to django...@googlegroups.com
But in mysite-mysite-settings.py in DATABASES I dont't have CONN_MAX_AGE and in don't have in my general directory file my.cnf :/ ????

Tom Evans

unread,
Jun 20, 2014, 1:59:39 PM6/20/14
to django...@googlegroups.com
On Fri, Jun 20, 2014 at 5:04 PM, Dariusz Mysior <mysior...@gmail.com> wrote:
> But in mysite-mysite-settings.py in DATABASES I dont't have CONN_MAX_AGE and
> in don't have in my general directory file my.cnf :/ ????

Helpfully, mysql uses my.cnf to refer to a whole raft of different
config files (or rather, multiple config files all called my.cnf get
read, combined in a specific order, and specific sections read
depending on what program is being run). You are saying your app - the
mysql client - does not have a my.cnf. Francois is saying that the
mysql server's my.cnf has that setting.

Even if it doesn't, it will have a default value. If the servers
"default" value differs from your client's "default" value then you
would have the same issue.

Cheers

Tom
Reply all
Reply to author
Forward
0 new messages