Configuring Django with MySQL syncdb gives a segmentation error?

I am currently working on a Django application. I follow the tutorial "tangowithdjango" which uses Django 1.54. They use Sql-lite in their tutorial, but I plan to build this application for the most reliable purpose, so I am trying to connect MySQL instead.

Needless to say, it was a nightmare. I can not get MySQL to connect to life.

Here is what my settings.py looks like:

DATABASE_PATH = os.path.join(PROJECT_PATH, 'app.db') DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'rideb', 'USER': 'root', 'PASSWORD': 'nantucket', #'HOST': 'localhost', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. #'PORT': '', # Set to empty string for default. } } 

And here is my conclusion that I get ...

 (rideb) grantmcgovern@gMAC :~/Dropbox/Developer/Projects/RideB/master$ python manage.py syncdb Segmentation fault: 11 

I installed python-mysqldb and now I just get this and I am very perplexed, to say the least. Is this a Django compatibility issue?

Everything works fine, as the SQL-lite tutorial suggests, but doesn't want to use it.

OS:

Mac OSX 10.10 Yosemite

MySQL (installed via .dmg on the Oracle website):

 Server version: 5.6.19 MySQL Community Server (GPL) 
+6
source share
2 answers

I had a similar problem and it turned out to be related to the wrong mysql implementation on my Mac (OS X 10.10 Yosemite). I had "mysql-connector-c" instead of "mysql". Removing "mysql-connector-c" (brew remove mysql-connector-c) and installing "mysql" (brew install mysql) immediately fixed the problem.

To find out if you are facing this exact problem, like me, open the Console application on your Mac, go to "User Diagnostic Reports" and find the report for your failure (you should start with Python_). In the queue, if it shows you "0 libmysqlclient.18.dylib", you have the same problem as mine.

+3
source

As already mentioned, you do not need DATABASE_PATH. My working configuration looks like this:

 DATABASES = { 'default': { 'ENGINE': 'mysql.connector.django', 'NAME': 'db_name', 'USER': 'db_user', 'PASSWORD': 'db_pass', 'HOST': '127.0.0.1', } } 

I use a different engine because it is needed for Python3. → see documentation

After that, you need to create the database and user. Do not forget to provide all necessary rights to the user.

With python manage.py migrate your database will be populated with your models.

syncdb predecessor to migrate will be removed in Django 1.9

0
source

Source: https://habr.com/ru/post/979470/


All Articles