django
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME':'djvue',
'USER':'root',
'PASSWORD':'123456',
'HOST':'192.168.7.211',
'PORT':'3306',
}
}
记住install pymysql
import pymysql
pymysql.install_as_MySQLdb()
注释掉
python manage.py makemigrations
python manage.py migrate
防火墙firewall
systemctl status firewalld查看状态
// --permanent 永久生效,没有此参数重启后失效
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --query-port=80/tcp查看是否开启端口
mysql
mysql> use mysql
mysql> select host,user from user;
mysql> update user set host = '%' where user = 'root' and host='127.0.0.1';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
可能需要刷新和给数据库权限
mysql>FLUSH PRIVILEGES;
mysql>grant all privileges on *.* to root@'%' identified by "123456";