django设置mysql数据库连接_django如何设置连接mysql数据库
django 的mysql數(shù)據(jù)配置 .
在成功安裝python-mysql后,開始配置django的mysql連接配置
打開django項(xiàng)目下的setting.py文件,將DATABASES改成下面這樣
DATABASES = {
'default': {
'ENGINE':'django.db.backends.mysql',#這里不是: 'ENGINE':'mysql'
'NAME':mycaipiao,#這里是你的具體數(shù)據(jù)庫名稱
'USER':'root',,#這里是你鏈接數(shù)據(jù)庫的用戶名
'PASSWORD':'123456.qq',#這里是你鏈接數(shù)據(jù)庫的密碼
'HOST':'127.0.0.1',#或者'HOST':'localhost'
'PORT':'3306',#這個(gè)是默認(rèn)端口,如果不一樣,請(qǐng)修改為具體的設(shè)置端口
}
}
最后進(jìn)入你的項(xiàng)目目錄下,manage.py所在目錄
運(yùn)行:
python manage.py dbshell
成功進(jìn)入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>
總結(jié)
以上是生活随笔為你收集整理的django设置mysql数据库连接_django如何设置连接mysql数据库的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: server 2008 配置php my
- 下一篇: mysql排列组合实现_Java实现数列