Tôi đã bắt đầu làm việc với django, và đây là lỗi trên 'runserver' sau khi thiết lập 'CƠ SỞ DỮ LIỆU' trong settings.pymysql_exceptions.OperationalError: (1045, "Truy cập bị từ chối cho người dùng 'root' @ 'localhost' (sử dụng mật khẩu: YES)")
mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
phần settings.py My mã:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'my_site', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': 'root', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
tôi đã tạo ra 'my_site' cơ sở dữ liệu và đặc quyền được thiết lập một cách đúng đắn (root có tất cả đặc quyền). Tôi đã thực hiện thao tác này với 'phpmyadmin'.
Điều gì xảy ra?
tôi thực sự muốn chạy lệnh này thông qua python. Nhưng tôi bị từ chối truy cập. Bất kỳ ý tưởng làm thế nào để tự động hóa điều này? Cảm ơn –