python manage.py migrate(错误)

时间:2018-06-18 18:35:40

标签: mysql django database migrate

执行命令python migrate.py migrate时遇到问题。 我正在学习一些关于django的知识,我需要将django与mysql数据库同步。

settings.py文件中,我输入了正确的数据库,用户名和root密码,我不知道为什么没有root权限。

所以这是我的错误:

(Ambientepython3) leonardo.oliveira@dss-skinner:~/django-tutorials/mysite$ python manage.py migrate
Traceback (most recent call last):
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
    self.connect()
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 229, in get_new_connection
    return Database.connect(**conn_params)
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/MySQLdb/__init__.py", line 86, in Connect
    return Connection(*args, **kwargs)
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1698, "Access denied for user 'root'@'localhost'")

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 "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/base.py", line 350, in execute
    self.check()
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/base.py", line 379, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 59, in _run_checks
    issues = run_checks(tags=[Tags.database])
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/checks/registry.py", line 71, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/core/checks/database.py", line 10, in check_database_backends
    issues.extend(conn.validation.check(**kwargs))
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 9, in check
    issues.extend(self._check_sql_mode(**kwargs))
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 13, in _check_sql_mode
    with self.connection.cursor() as cursor:
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 255, in cursor
    return self._cursor()
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 232, in _cursor
    self.ensure_connection()
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
    self.connect()
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
    self.connect()
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 229, in get_new_connection
    return Database.connect(**conn_params)
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/MySQLdb/__init__.py", line 86, in Connect
    return Connection(*args, **kwargs)
  File "/home/leonardo.oliveira/django-tutorials/Ambientepython3/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1698, "Access denied for user 'root'@'localhost'")

0 个答案:

没有答案