Django mysql 1045_Django:mysql:1045,“Access denied for user”

bd96500e110b49cbb3cd949968f18be7.png

I have the whole setup working for months on my local computer.

I'm installing on a remote site now.

Created a fresh mysql DB, and created a new user ("someuser") and gave it complete grants, like so -

GRANT ALL PRIVILEGES ON . TO 'someuser'@'localhost' IDENTIFIED BY 'somepassword' WITH GRANT OPTION;

I have sync'd the db, using "python manage.py syncdb" and the correct tables were created.

My settings.py has this same user.

But when I try to login a user through the application, and it hits the DB, I see the following in the logs -

(1045, "Access denied for user 'someuser'@'localhost' (using password: YES)")

I logged in through mysql (installed on the same box as django) and checked the grants and it correctly shows -

Grants for someuser@localhost

GRANT ALL PRIVILEGES ON * . * TO 'someuser'@'localhost' IDENTIFIED BY PASSWORD '*thesaltedpasswordOverHere' WITH GRANT OPTION

I don't want to use the root user/password for django, since it doesn't seem the correct way.

Any pointers as to what might be wrong ?

解决方案

I do it like this for a database named foo_db:

create database foo_db;

create user foo_user identified by 'foo_password';

grant all on foo_db.* to 'foo_user'@'%';

flush privileges;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值