image-20200716203109242
create database luffyapi;
image-20200716203145746
grant all privileges on luffyapi.* to 'luffyapi'@'%' identified by 'Luffy123?';
grant all privileges on luffyapi.* to 'luffyapi'@'localhost' identified by 'Luffy123?';
flush privileges;
image-20200716204204339
image-20200716204135193
image-20200716204456156
连接名:自定义,见名知意即可
主机:默认本机是 localhost,远程连接就填IP
端口:默认是3306,无需改动
用户名:第3步创建的用户名
密码:第3步创建的密码
image-20200716204639188
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'luffy',
'USER': 'luffy',
'PASSWORD': 'Luffy123?',
'HOST': 'localhost',
'PORT': 3306
}
}
import pymysql
pymysql.install_as_MySQLdb()
image-20200716205149865
image-20200716205600485
image-20200716211414293
image-20200716211529444
image-20200716212102400
image-20200716211621612