Unable to access mysql db and apply changes using "python manage.py migrate"

662 views
Skip to first unread message

Emmanuel klutse

unread,
Feb 2, 2019, 4:07:36 AM2/2/19
to Django users
hello team,
Can someone help me with the problem below please.
(py1) C:\djangoproject>python manage.py migrate
Traceback (most recent call last):
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\db\backends\mysql\base.py", line 227, in get_new_connection
    return Database.connect(**conn_params)
  File "C:\Users\Success\Envs\py1\lib\site-packages\MySQLdb\__init__.py", line 84, in Connect
    return Connection(*args, **kwargs)
  File "C:\Users\Success\Envs\py1\lib\site-packages\MySQLdb\connections.py", line 164, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\core\management\base.py", line 350, in execute
    self.check()
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\core\management\base.py", line 379, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\core\management\commands\migrate.py", line 59, in _run_checks
    issues = run_checks(tags=[Tags.database])
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\Success\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\Success\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\Success\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\Success\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 255, in cursor
    return self._cursor()
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 232, in _cursor
    self.ensure_connection()
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\db\utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\Success\Envs\py1\lib\site-packages\django\db\backends\mysql\base.py", line 227, in get_new_connection
    return Database.connect(**conn_params)
  File "C:\Users\Success\Envs\py1\lib\site-packages\MySQLdb\__init__.py", line 84, in Connect
    return Connection(*args, **kwargs)
  File "C:\Users\Success\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: Y

Carsten Fuchs

unread,
Feb 2, 2019, 4:11:38 AM2/2/19
to django...@googlegroups.com
Hi Emmanuel,

the error message is clear, isn't it?
(1045, "Access denied for user 'root'@'localhost' (using password: YES)")

Check your password. Use the mysql client to check.

Best regards,
Carsten


Am 02.02.19 um 10:07 schrieb Emmanuel klutse:

Emmanuel klutse

unread,
Feb 2, 2019, 4:33:00 AM2/2/19
to Django users
hello Carsten Fuchs,
thanks for your feedback.
yes, i agree. but what i dont understand is that the command used "python manage.py migrate" is to creat a db for me in mysql instead of sqlite and the error is talking about authentication.
these are the changes made in my djangoproject/settings file:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'djangoproject',
        'USER': 'root',
        'PASSWORD': '123456',
        'HOST': "localhost",
        'PORT': ''
    }
}
i'm confuse now.

Carsten Fuchs

unread,
Feb 2, 2019, 4:47:39 AM2/2/19
to django...@googlegroups.com
Am 02.02.19 um 10:33 schrieb Emmanuel klutse:
> [...] creat a db for me in mysql instead of sqlite and the error is talking about authentication.
> these are the changes made in my djangoproject/settings file:
> DATABASES = {
>     'default': {
>         'ENGINE': 'django.db.backends.mysql',

You are asking for mysql.

Emmanuel klutse

unread,
Feb 2, 2019, 5:09:53 AM2/2/19
to Django users

Emmanuel klutse

unread,
Feb 2, 2019, 5:10:59 AM2/2/19
to Django users

yes im talking about using "python manage.py migrate" command to create tables in the db(djangoproject) i have already created in mysql server

On Saturday, February 2, 2019 at 2:09:53 AM UTC-8, Emmanuel klutse wrote:


On Saturday, February 2, 2019 at 1:47:39 AM UTC-8, Carsten Fuchs wrote:
Am 02.02.19 um 10:33 schrieb Emmanuel klutse:
> [...] creat a db for me in mysql instead of sqlite and the error is talking about authentication.
> these are the changes made in my djangoproject/settings file:
> DATABASES = {
>     'default': {
yes im talking about using "python manage.py migrate" command to create tables in the db(djangoproject) i have already created in mysql server

Carsten Fuchs

unread,
Feb 2, 2019, 5:33:37 AM2/2/19
to django...@googlegroups.com
Am 02.02.19 um 11:10 schrieb Emmanuel klutse:
> yes im talking about using "python manage.py migrate" command to create tables in the db(djangoproject) i have already created in mysql server

`manage.py migrate` is trying to access your MySQL database, but the database denies the access to the user that is configured in your settings.
To fix this, you have to figure out why that is.

Emmanuel klutse

unread,
Feb 2, 2019, 6:42:20 AM2/2/19
to django...@googlegroups.com
Thx a lot I will look into it n revert 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/248b2ffc-85bf-fbd3-d0f8-f05e9bf34761%40cafu.de.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages