django 的mysql数据配置 .
在成功安装python-mysql后,开始配置django的mysql连接配置
打开django项目下的setting.py文件,将DATABASES改成下面这样
DATABASES = {
'default': {
'ENGINE':'django.db.backends.mysql',#这里不是: 'ENGINE':'mysql'
'NAME':mycaipiao,#这里是你的具体数据库名称
'USER':'root',,#这里是你链接数据库的用户名
'PASSWORD':'123456.qq',#这里是你链接数据库的密码
'HOST':'127.0.0.1',#或者'HOST':'localhost'
'PORT':'3306',#这个是默认端口,如果不一样,请修改为具体的设置端口
}
}
最后进入你的项目目录下,manage.py所在目录
运行:
python manage.py dbshell
成功进入mysql shell
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.6.21-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>