python - django.db.utils.OperationalError: (1045, "Access denied for user 'someuser'@'localhost' (using password: NO)") -
i getting error when try run
python manage.py migrate
django.db.utils.operationalerror: (1045, "access denied user 'someuser'@'localhost' (using password: no)")
this database setting inside setting.py
databases = { 'default': { 'engine': 'django.db.backends.mysql', 'options': { 'read_default_file': '/config/mysql.cnf', }, } }
config/mysql.cnf
[client]
database = dbname
user = root
password = passwt
host = localhost
default-character-set = utf8
the mysql configs can provided in settings.py file, below
databases = { 'default': { 'engine': 'django.db.backends.mysql', 'name': 'db_name', 'user': 'db_user', 'password': 'db_password', 'host': 'localhost', # or ip address db hosted on 'port': '3306', 'options': { 'init_command': "set sql_mode='strict_trans_tables'", 'charset': 'utf8mb4', } } }
if need configure external file, below may helpful
databases = { 'default': { 'engine': 'django.db.backends.mysql', 'options': { 'read_default_file': os.path.join(base_dir, 'mysql.cnf'), } } }
the mysql.cnf
file should in project dir
wiki
Comments
Post a Comment