标签:code 限制 select src exit png import setting img
"""
1.管理员连接数据库
2.创建数据库
>: create database luffy default charset=utf8;
3.以管理员身份登录数据库
>: mysql -uroot -p123
4.查看用户
>: select user,host,password from mysql.user;
5.设置权限账号密码
# 授权账号命令:grant 权限(create, update) on 库.表 to '账号'@'host' identified by '密码'
>: grant all privileges on luffy.* to 'luffy'@'%' identified by 'luffy';
# 要是本机连mysql连不上,再添加localhost访问权限,本机就可以登录了
>: grant all privileges on luffy.* to 'luffy'@'localhost' identified by 'luffy';
# 设置完有权限限制的账号后一定要刷新权限,如果没刷新权限,该终端无法被通知
>: flush privileges;
6.退出管理员,用账号 luffy 密码 luffy 登入开发
>: exit
>: mysql -uluffy -pluffy
# 后台项目进行数据库配置
7.luffyapi/settings/dev.py配置
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"HOST": "127.0.0.1",
"PORT": 3306,
"USER": "luffy",
"PASSWORD": "luffy",
"NAME": "luffy",
}
}
6.luffypai/__init__.py
import pymysql
pymysql.install_as_MySQLdb()
7.运行会出现Django与pymysql版本兼容问题:见两张插图
"""
标签:code 限制 select src exit png import setting img
原文地址:https://www.cnblogs.com/king-home/p/11197530.html