1
votes

I am new to django, I was running the command

python manage.py migrate

and got this error.

(py1) G:\django\djangoproject1>python manage.py migrate Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management__init__.py", line 364, in execute_from_command_line utility.execute() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management\base.py", line 327, in execute self.check() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management\base.py", line 359, in check include_deployment_checks=include_deployment_checks, File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management\commands\migrate.py", line 61, in _run_checks issues = run_checks(tags=[Tags.database]) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\checks\database.py", line 10, in check_database_backends issues.extend(conn.validation.check(**kwargs)) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\mysql\validation.py", line 9, in check issues.extend(self._check_sql_mode(**kwargs)) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\mysql\validation.py", line 13, in _check_sql_mode with self.connection.cursor() as cursor: File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 254, in cursor return self._cursor() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 229, in _cursor self.ensure_connection() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection self.connect() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\utils.py", line 94, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection self.connect() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 189, in connect self.connection = self.get_new_connection(conn_params) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\mysql\base.py", line 274, in get_new_connection conn = Database.connect(**conn_params) File "C:\Users\Mahin\Envs\py1\lib\site-packages\MySQLdb__init__.py", line 84, in Connect return Connection(*args, **kwargs) File "C:\Users\Mahin\Envs\py1\lib\site-packages\MySQLdb\connections.py", line 164, in init super(Connection, self).init(*args, **kwargs2) django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

1
Isn't it self explanatory? MySQL credentials are not ok.Alex
"Access denied for user 'root'@'localhost' (using password: YES)"ninjabber
where should I change this?Mahin Malhotra

1 Answers

1
votes

Since I should have magically known your settings.py DB config and my post was deleted for not answering the question without "requiring clarification from the asker" I'm reposting to try and help. The default password for root user in a mysql db is "", that is its left blank. Right now there is a mismatch between your db and the configuration you provided in your settings.py file. Go into your dbms and make sure that the setting for the database match the ones you provided in your settings.py.

DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'DB NAME',
            'USER': 'USER NAME',
            'PASSWORD':'USER PW',
            'HOST' : 'localhost',
        }
    }

If these match to your db you should be able to now migrate.