19๐
You need to make changes in project settings.py. Provide USER
and PASSWORD
for your database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myproject',
'USER': 'root',
'PASSWORD': 'rootpassword',
'HOST': 'localhost',
'PORT': '',
}
}
2๐
Check Your Database Username and Password. many time, we do typing mistake. it doesnโt match from the database username and password so occur this error. I faced this error and trust me, it is my very bad experience.
2๐
I had the same error and changing the HOST
to 127.0.0.1
and removing the password worked for me. You can try it out and see if it will work for you as well.
- Uwsgi segmentation fault when serving a django application
- Return list of objects as dictionary with keys as the objects id with django rest framerwork
- Django: Duplicated logic between properties and queryset annotations
- 'QuerySet' object has no attribute ERROR, trying to get related data on ManyToMany fields
0๐
I saw this error message after copying my project onto a new machine from a backup file. An additional error message explained the problem:
[Warning] World-writable config file '/home/myuser/myproject/database.cnf' is ignored.
The permissions of my database configuration file had been changed and it was not being loaded, therefore Django was trying to connect with the wrong user. I fixed this by running:
chmod 600 database.cnf
- How should multiple Django apps communicate with each other?
- Django cms โ invalid block tag endblock
- Error loading MySQLdb module: libmysqlclient.so.20: cannot open shared object file: No such file or directory
- Selenium โ python. how to capture network traffic's response
0๐
I accidentally used USERNAME:
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'inventory',
'HOST': '127.0.0.1',
'USERNAME': 'root',
'PORT': '',
'PASSWORD': '', # Your Password
}
Just change it to USER
- TimeField format in Django template
- How to resolve the "psycopg2.errors.UndefinedTable: relation "auth_user" does not exist" when running django unittests on Travis
- Django rest auth email instead of username
- How to test django caching?
0๐
Remove the password field if not set.
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": "reservations",
"HOST": "127.0.0.1",
"PORT": "3306",
"USER": "root",
}
}
Add this snippet of code.
0๐
In My case I was using the wrong port number, I have configured the MySql on 3307 and was using 3306 in the settings.py
file
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": "reservations",
"HOST": "127.0.0.1",
"PORT": "3307",
"USER": "root",
}
}
-1๐
I had the same problem and I learn from linuxnightly.com that it is caused by auth socket plugin, once you disable it the problem is solved.
Try running the following commands after you are logged into mysql as root:
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password_here';
mysql> exit;
$ sudo systemctl restart mysql
To make this work, you have to change rootโs password. This is done by the UPDATE
command. You have to restart mysql at the end of the process with the systemctl
command at the end.
source: https://linuxnightly.com/error-1698-28000-access-denied-for-user-rootlocalhost/
- Django runserver custom database
- Django string concatenation inside template tag best practice
- How to concatenate two model fields in a Django QuerySet?