1👍
I am a mac user. I have luckily overcome the issue with connecting Django to mysql workbench. I assume that you have already installed Django package created your project directory e.g. mysite.
- Initially after installation of MySQL workbench i have created a database : create database djo;
- Go to mysite/settings.py and edit following piece of block.
NOTE: Keep Engine name “django.db.backends.mysql” while using MySQL server.
and STOP the other Django MySQL service which might be running.
DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.mysql’, # Add ‘postgresql_psycopg2’, ‘mysql’, ‘sqlite3’ or ‘oracle’.
‘NAME’: ‘djo’, # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
‘USER’: ‘root’,
‘PASSWORD’: ‘****’, # Replace **** with your set password.
‘HOST’: ‘127.0.0.1’, # Empty for localhost through domain sockets or ‘127.0.0.1’ for localhost through TCP.
‘PORT’: ‘3306’, # Set to empty string for default.
}
}
- now run manage.py to sync your database :
$ python mysite/manage.py syncdb
bash-3.2$ python manage.py syncdb
Creating tables …
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
You just installed Django’s auth system, which means you don’t have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use ‘ambershe’): root
Email address: ambershe@netapp.com
/Users/ambershe/Library/Containers/com.bitnami.django/Data/app/python/lib/python2.7/getpass.py:83: GetPassWarning: Can not control echo on the terminal.
passwd = fallback_getpass(prompt, stream)
Warning: Password input may be echoed.
Password: ****
Warning: Password input may be echoed.
Password (again): ****
Superuser created successfully.
Installing custom SQL …
Installing indexes …
Installed 0 object(s) from 0 fixture(s)