Reputation: 738
Explanation: I have 2 instances of Amazon Lightsail. One has MYSQL and the other has CentOs. I have my app Django with apache mod_wsgi, for connecting Django(instance 1) to Mysql(instance 2) using the endpoint from Amazon:
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:
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)
please some one suggest..!!
Upvotes: 1
Views: 860
Reputation: 738
The solution was : change SERVER by HOST: on the setup Django only change this:
'SERVER':'my_server'
by:
'HOST':'my_server'
is very strange but with this change i can connect to my server mysql amazon.
Upvotes: 1
Reputation: 725
Where is MySQL running:
Localhost alongside Django? An instance you hand built and installed MySQL on? A Lightsail database instance?
My suspicion is that your 'SERVER':'host_amazon'
parameter is incorrect. 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
)
How did you create the user? What server did you connect to?
Upvotes: 0