[英]Connect Django Amazon Lightsail Mysql
Explanation: I have 2 instances of Amazon Lightsail.说明:我有 2 个 Amazon Lightsail 实例。 One has MYSQL and the other has CentOs .
一个有MYSQL ,一个有CentOs 。 I have my app Django with apache mod_wsgi, for connecting Django(instance 1) to Mysql(instance 2) using the endpoint from Amazon:
我有我的应用程序 Django 和 apache mod_wsgi,用于使用来自亚马逊的端点将 Django(实例 1)连接到 Mysql(实例 2):
ls-846d543ff0bab456d8a9309bd9585f11072f.cqaexlou8v8h.us-east-1.rds.amazonaws.com
and I get this error:我得到这个错误:
(1045, u"Access denied for user 'toor'@'localhost' (using password: YES)")
my settings:我的设置:
DATABASES = {
'default':{
'ENGINE': 'django.db.backends.mysql',
'NAME': 'my_db',
'SERVER':'ls-846d543ff0bab456d8a9309bd9585f11072f.cqaexlou8v8h.us-east-1.rds.amazonaws.com',
'PORT': '3306',
'USER': 'toor',
'PASSWORD': 'q1w2e3r4t5' ,
}
}
I created a user using mySQL Workbench like this:我使用 mySQL Workbench 创建了一个用户,如下所示:
create user toor identified by 'q1w2e3r4t5';
grant all on my_db.* to 'toor'@'%';
flush privileges;
and try this code:并尝试此代码:
grant all on my_db.* to toor@localhost identified by 'q1w2e3r4t5' with grant option;
I create this user by Mysql Workbench with instance2(mysql amazon Lightsail)我通过 Mysql Workbench 使用 instance2(mysql amazon Lightsail) 创建了这个用户
please some one suggest..!!请有人建议..!!
The solution was: change SERVER by HOST : on the setup Django only change this:解决方案是:通过HOST更改SERVER :在设置 Django 时只更改此:
'SERVER':'my_server'
by:经过:
'HOST':'my_server'
is very strange but with this change i can connect to my server mysql amazon.很奇怪,但是有了这个改变,我可以连接到我的服务器 mysql amazon。
Where is MySQL running: MySQL在哪里运行:
Localhost alongside Django? Localhost 和 Django 一起? An instance you hand built and installed MySQL on?
您手动构建并安装了 MySQL 的实例? A Lightsail database instance?
Lightsail 数据库实例?
My suspicion is that your 'SERVER':'host_amazon'
parameter is incorrect.我怀疑您
'SERVER':'host_amazon'
参数不正确。 As I'd expect it to either be localhost
, the internal IP of your custom built instance, or the endpoint of your Lightsail database (something like: ls-7d2174226335104ebdb71cfebe89d1c8f060c799.cdekwlh0imih.us-west-2.rds.amazonaws.com
)正如我所期望的那样,它要么是
localhost
,您的自定义构建实例的内部 IP,要么是您的 Lightsail 数据库的端点(类似于: ls-7d2174226335104ebdb71cfebe89d1c8f060c799.cdekwlh0imih.us-west-2.rds.amazonaws.com
)
How did you create the user?你是如何创建用户的? What server did you connect to?
你连接到什么服务器?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.