I would like to start using Django with MYSQL, instead of sqlite all the time, however my only experience using MSQL is through XAMPP, manipulating databases through phpmyadmin. I would really like to keep this gui interaction with mysql and not have to do everything through command line.
Can you start and manage a MYSQL database using xampp/phpmyadmin, and then use django for the web development side only using Django'sn development server?
Or do you have to always start new databases through command line, and if so how is it done, bearing in mind I only ever use mysql through xampp/phpmyadmin?
I know how to link and manage a database through django, I just dont know how to start a mysql one through it, and I dont really want to have to loose the mysql gui that comes with xampp/phpmyadmin. all help is greatly appreciated.
You can definitely manage Mysql through the XAMPP interface. Try setting the DB_HOST in settings.py to "localhost". If it doesn't work, try "127.0.0.1". This is typically caused by the python-mysql module expecting the mysql unix socket to be in another place than it is. Actually, I'm unsure if the mysql server uses a unix socket on Windows. Anyway, one of both should work :) You can use the credentials you use to login with phpmyAdmin also for Django. Many consider it bad style to use root for non-administration tasks (and I agree), but for starters and on your development machine it isn't too big of an issue. phpMyAdmin should work out of the box with your django-managed databases.
My database settings.py block for mysql looks something like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'DBNAME', # Or path to database file if using sqlite3.
'USER': 'USER', # Not used with sqlite3.
'PASSWORD': 'PASSWORD', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
This is for django 1.2 and above. Replace DBNAME, USER and PASSWORD with the respective values and try '127.0.0.1' as HOST if you run into problems. Obviously, you'd need to run 'manage.py syncdb' as you did with sqlite before you can use it.