将Django连接到本地网络上的远程mysql服务器 [英] Connect Django to remote mysql server on a local network
问题描述
本地主机是:192.168.1.51 (又名笔记本电脑)
远程是:192.168.1.50(又名桌面)
settings.py看起来像这样:
DATABASES = {
'default':{
'ENGINE':'django.db.backends.mysql',
'NAME':'mydb',
'USER':'root',
'PASSWORD':'mypass',
'HOST':'192.168.1.50',
'PORT':'3306',
}
}
运行'python manage.py runserver'并得到一个错误:
_mysql_exceptions.OperationalError:(1045,访问被拒绝为用户' @'laptop.local'(我们密码:YES))
我已经授权访问root @ laptop,但是我无法弄明白为什么正在添加'.local'....我正在这样做吗?
默认情况下,root帐户只能使用在本地登录到mysql。您首先需要从主机授予root用户登录权限。
I have setup Django and am a complete newb. I have successfully connected to a mysql database on my localhost but have had trouble connecting to a database that's hosted on another machine on my local network.
Localhost is: 192.168.1.51 (aka "laptop") Remote is: 192.168.1.50 (aka "desktop")
settings.py looks like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydb',
'USER': 'root',
'PASSWORD': 'mypass',
'HOST': '192.168.1.50',
'PORT': '3306',
}
}
I run 'python manage.py runserver' and get an error:
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'laptop.local' (using password: YES)")
I've granted access to 'root@laptop' but I can't figure out why it is adding '.local'....Am I doing this right?
In default, root account only can be used to login to mysql locally. You need give root user logon permission from the host at first.
这篇关于将Django连接到本地网络上的远程mysql服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!