我遇到过这篇文章:Mac OSX 10.6上的Python mysqldb没有工作,看到了两个选项:
将MySQL客户端库添加到LD_LIBRARY_PATH
mysql_config --libs -L/usr/local/mysql/lib -lmysqlclient -lpthread
所以我不需要在这做任何事情.
成功安装django并运行virtualenvs环境并使用sqlite3创建项目.我想用mysql来管理数据库.
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'blog', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': 'root', # Not used with sqlite3.
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for …Run Code Online (Sandbox Code Playgroud)