1


I'm a Django newby (I started yesterday) and I'm trying to configure the DB. But since I think I'll always be using Django with MySQL I want to set it up. I read the doc and I saw that in order to use MySQL you have to install a module, and so I did. I installed mysqlclient since installing MySQLdb with pip return:

$ pip2 install mysqldb

Could not find a version that satisfies the requirement mysqldb (from versions: )
No matching distribution found for mysqldb

and the Oracle solution isn't working at all (django don't recognize it). So I entered my credentials, and it look like this in project's settings.py:

DATABASES = {
    'default': {
        # 'ENGINE': 'django.db.backends.sqlite3',
        # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'dbname_entered_and_tested',
        'USER': 'username_entered_and_tested',
        'PASSWORD': 'correct_password',
        'HOST': 'externale.domain_name_to_db.com',
        'PORT': '3306',

    }
}

So it returned me

$ python manage.py runserver

... 30 lines of Exceptions ...

django.db.utils.OperationalError: (2026, 'SSL connection error: error:00000001:lib(0):func(0):reason(1)')

So I googled and I found Django AWS RDS MySQL Error: (2026, 'SSL connection error: error:00000001:lib(0):func(0):reason(1)')

So I set my settings to:

DATABASES = {
    'default': {
        # 'ENGINE': 'django.db.backends.sqlite3',
        # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'dbname_entered_and_tested',
        'USER': 'username_entered_and_tested',
        'PASSWORD': 'correct_password',
        'HOST': 'externale.domain_name_to_db.com',
        'PORT': '3306',
        'OPTIONS': {
            'skip-ssl',
        },
    }
}

And it returned me

 $ python manager.py runserver

 ... 30 lines of Exceptions ...

 ValueError: dictionary update sequence element #0 has length 8; 2 is required

So I managed to generate my own certificats after reading another stackoverflow post, using OpenSSL and the MySQL doc (https://dev.mysql.com/doc/refman/5.6/en/creating-ssl-files-using-openssl.html) and I succeded, but django threw the same:

 django.db.utils.OperationalError: (2026, 'SSL connection error: error:00000001:lib(0):func(0):reason(1)')

I already tried connecting with multiple other clients to my db using the same credentials, disabling SSL, enabling SSL, another user account.

I found a solution but it involve downgrading the MySQL version to 5.6.27 (Django server not starting correctly seems to be a mysql issue.) and it won't be a problem... if I only could :C . The MySQL database since to be a pain for a lot of Django users (so much post talking about that out there ...) and I'm just a newbie but I don't want to be discouraged by a simple bug and stop Django :S

So, does someone have an answer ?

EDIT: I'm using the latest version of both django, pip and mysqlclient

Samuel Prevost
  • 1,047
  • 1
  • 11
  • 30
  • This might help: [How to connect Django to a mysql database over an ssl connection?](http://stackoverflow.com/q/4323737/1396314) – flowfree Jun 16 '16 at 15:34
  • Yeah, I know as said, "I managed to generate my own certificats after reading another stackoverflow post", I referred to this post but I wasn't able to found it anymore :S – Samuel Prevost Jun 16 '16 at 15:36
  • The package name of MySQLdb that you install via pip is `mysql-python`, not `mysqldb` – Daniel Roseman Jun 16 '16 at 15:40
  • Once again, as I told in the post, "and the Oracle solution isn't working at all (django don't recognize it).". After installing mysql-python, django return `django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb`. I already fixed this issue by installing mysqlclient using `pip2 install mysqlclient` – Samuel Prevost Jun 16 '16 at 15:44

0 Answers0