时间:2021-07-01 10:21:17 帮助过:4人阅读
""" 1.管理员连接数据库 >: mysql -uroot -proot ? 2.创建数据库 >: create database luffy default charset=utf8; ? 3.查看用户 >: select user,host,password from mysql.user; """
""" 设置权限账号密码 # 授权账号命令:grant 权限(create, update) on 库.表 to ‘账号‘@‘host‘ identified by ‘密码‘ ? 1.配置任意ip都可以连入数据库的账户 >: grant all privileges on luffy.* to ‘luffy‘@‘%‘ identified by ‘Luffy123?‘; ? 2.由于数据库版本的问题,可能本地还连接不上,就给本地用户单独配置 >: grant all privileges on luffy.* to ‘luffy‘@‘localhost‘ identified by ‘Luffy123?‘; ? 3.刷新一下权限 >: flush privileges; ? 只能操作luffy数据库的账户 账号:luffy 密码:Luffy123? >: mysql -uluffy -pluffy 4.后台项目进行数据库配置 luffyapi/settings/dev.py配置 DATABASES = { "default": { "ENGINE": "django.db.backends.mysql", "HOST": "127.0.0.1", "PORT": 3306, "USER": "luffy", "PASSWORD": "luffy", "NAME": "luffy", } } 5.luffypai/__init__.py import pymysql pymysql.install_as_MySQLdb()
注意: 配置mysql数控时,要在django.setup()前配置 建议直接配置在dev.py文件中 """
数据库配置
标签:ade mys create inf post flush ant span set