1.django.db.utils.OperationalError: (2003, “Can’t connect to MySQL server on ‘服务器地址’ ([Errno 113] No route to host)”)
我出现这个问题百度了很多,但还是没找到解决问题的办法,最后亲测 防火墙没有关闭,把防火墙关闭就好了。
systemctl start firewalld # 开启防火墙
systemctl stop firewalld # 关闭防火墙
systemctl status firewalld #检查防火墙状态
还有 你可能需要 在你的mysql的my.cnf文件加入:
[mysqld]
bind-address = 0.0.0.0 # 表示允许任何主机登陆MySQL
port=3306 # 表示MySQL运行端口为3306
2.django连接远程服务器时报错:django.db.utils.OperationalError: (1045, “Access denied for user ‘root’@‘服务器地址’ (using password: YES)”)
第一有可能你密码真的输错了检查一下有没有输错
第二就是你服务器的mysql免密码登陆就是直接输入mysql回车直接进入到mysql就是免密码登陆了。 如果说你是没有设置密码导致的, 那就先选择你的mysql库 use mysql
,然后使用sql语句 select host, user from user;
查看你的状态
如果你的root只有 localhost 那就需要新增一条,允许所有地址访问
向user表新增user=root,host=%的数据
update user set host='%' where user='root'
5.7版本使用update mysql.user set authentication_string=password("你的密码") where user='root';
5.7以下的使用:update user set password=password("你的密码") where user="root";
然后 flush privileges;
就ok了!
第一次发表,写的不好 希望能帮助到所有有需要的同志!!