问题描述
我已经设置了Django,并且是一个完整的新手。我已经成功地连接到我的本地主机上的一个mysql数据库,但连接到本地网络上另一台机器上托管的数据库时遇到麻烦。本地主机是: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'并得到一个错误:
我已经授权访问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:
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服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!