Django, MySQL, and Windows 7 64-bit installation tips
Here are the solutions to a few annoying things that caused issues when I was installing Python, Django, and MySQL on a new Windows 7 64-bit laptop.
1. Be sure to set your PYTHONPATH variable.
After I installed ActiveState Python, it didn't set up the environmental variable. I added it and restarted the command window, and voilà. (I don't remember having to set that up manually on my XP machine, but I could be mistaken since it's been a very long time since I installed everything on that machine. Regardless, it's a good thing to check. *g* Also check your PATH variable, to make sure that Python, Django, and MySQL are all in there.)
2. Assign the read_default_file setting in the database dictionary.
I was getting "Error 2003: Can't connect to MySQL server on 'localhost' (10061)." It wasn't the firewall blocking the port, because mysql is running on a socket. (Though I could be wrong, as I just switched over to Codomo from ZoneAlarm, which had issues with Win7 64-bit and Filezilla, and I haven't learned all of Codomo's quirks yet, so who knows?) Even though I've got the admin service set up to execute "C:\progs\mysql\bin\mysqld" --defaults-file="C:\progs\mysql\my.ini" MySQL
, it still wasn't finding the ini file for some reason. Weirdly, telling Django which my.ini file to run MySQL with fixed it. In your settings.py
, in the database section, you'll add the OPTIONS
entry:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'database_name', 'USER': 'username', 'PASSWORD': 'password', 'HOST': '', 'PORT': '', 'OPTIONS': { 'read_default_file': 'c:\path\to\your\my.ini', }, } }