django1.6 mysql_python2.7+django1.6 连接MySQL8

项目版本

Python 2.7.10 + Django 1.6.11 + MySQL 8.0.19

$ python --version

Python 2.7.10

$ python -c "import django; print(django.get_version())"

1.6.11

$ mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 20

Server version: 8.0.19 MySQL Community Server - GPL

使用PyMySQL模块

$ pip install PyMySQL

......

Successfully installed PyMySQL-0.9.3

更改Django配置

在站点的init.py文件中必须加入一下的代码:

import pymysql

pymysql.install_as_MySQLdb()

验证

在django项目目录中执行:

$ python manage.py syncdb

Creating tables ...

Creating table django_admin_log

Creating table auth_permission

Creating table auth_group_permissions

Creating table auth_group

Creating table auth_user_groups

Creating table auth_user_user_permissions

Creating table auth_user

Creating table django_content_type

Creating table django_session

You just installed Django's auth system, which means you don't have any superusers defined.

Would you like to create one now? (yes/no): yes

Username (leave blank to use 'xxx'): admin

Email address: xxx

Password:

Password (again):

Superuser created successfully.

Installing custom SQL ...

Installing indexes ...

Installed 0 object(s) from 0 fixture(s)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值