美文网首页《Django By Example》
记坑: django 连接远程 MySQL 数据库错误

记坑: django 连接远程 MySQL 数据库错误

作者: 大白杏仁 | 来源:发表于2018-01-10 22:46 被阅读23次

# 问题:

在 Mac 里写的代码,MySQL 数据库在 Ubuntu 虚拟机里,当我模型类写完之后执行 python manage.py makemigrations 要准备生成迁移文件时报错了,大概是权限不够 access denied 等提示,后来了解到默认情况下 root 用户是不支持远程登录的权限,接下来要做的及时用户账号提权

# 解决:

在 Ubuntu 中登录 MySQL
1. 执行

Grant all privileges on *.* to 'root'@'%' identified by 'mysql' with grant option;

'root' 即当前用户名,'mysql' 是我自己设定的密码

2. 执行

flush privileges;

之后就会重新加载数据,或者不输入命令关掉终端重新打开

听说这幅画里有 820 只神奇宝贝🙂


by ccayco

相关文章

网友评论

    本文标题:记坑: django 连接远程 MySQL 数据库错误

    本文链接:https://www.haomeiwen.com/subject/ahdcnxtx.html