- Django项目目录下
settings.py
DATABASES = {
'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.mysql',
'NAME': 'hello_world', # 数据库名称,需要事先创建对应的mysql数据库
'HOST': '127.0.0.1', # 主机,127.0.0.1为本机
'PORT': '3306', # 端口号
'USER': 'root', # mysql用户名
'PASSWORD': '123456', # mysql密码
}
}
-
安装mysql数据库驱动,ubuntu18 安装mysqlclient