2017-03-06 25 views
-4

我想運行一個程序,我被看作是一個例子,它就像一個購物網站,它使用MySQL數據庫而不是Django提供的原始數據庫!我只是想看看是否有人明白這些錯誤是什麼意思?任何信息,將不勝感激!我會提供網頁的代碼,但有很多它不適合!這些錯誤是什麼意思? mysql在django

Traceback (most recent call last): 
    File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run 
    self.check(display_num_errors=True) 
    File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 374, in check 
    include_deployment_checks=include_deployment_checks, 
    File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 361, in _run_checks 
    return checks.run_checks(**kwargs) 
    File "/Library/Python/2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks 
    new_errors = check(app_configs=app_configs) 
    File "/Library/Python/2.7/site-packages/django/core/checks/model_checks.py", line 30, in check_all_models 
    errors.extend(model.check(**kwargs)) 
    File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 1266, in check 
    errors.extend(cls._check_fields(**kwargs)) 
    File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 1337, in _check_fields 
    errors.extend(field.check(**kwargs)) 
    File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 893, in check 
    errors = super(AutoField, self).check(**kwargs) 
    File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 208, in check 
    errors.extend(self._check_backend_specific_checks(**kwargs)) 
    File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 311, in _check_backend_specific_checks 
    return connections[db].validation.check_field(self, **kwargs) 
    File "/Library/Python/2.7/site-packages/django/db/backends/mysql/validation.py", line 41, in check_field 
    field_type = field.db_type(connection) 
    File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 629, in db_type 
    return connection.data_types[self.get_internal_type()] % data 
    File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 33, in __getattr__ 
    return getattr(connections[DEFAULT_DB_ALIAS], item) 
    File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 35, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 183, in data_types 
    if self.features.supports_microsecond_precision: 
    File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 35, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "/Library/Python/2.7/site-packages/django/db/backends/mysql/features.py", line 54, in supports_microsecond_precision 
    return self.connection.mysql_version >= (5, 6, 4) and Database.version_info >= (1, 2, 5) 
    File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 35, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 367, in mysql_version 
    with self.temporary_connection() as cursor: 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__ 
    return self.gen.next() 
    File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 564, in temporary_connection 
    cursor = self.cursor() 
    File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 231, in cursor 
    cursor = self.make_debug_cursor(self._cursor()) 
    File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 204, in _cursor 
    self.ensure_connection() 
    File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection 
    self.connect() 
    File "/Library/Python/2.7/site-packages/django/db/utils.py", line 94, in __exit__ 
    six.reraise(dj_exc_type, dj_exc_value, traceback) 
    File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection 
    self.connect() 
    File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 171, in connect 
    self.connection = self.get_new_connection(conn_params) 
    File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 263, in get_new_connection 
    conn = Database.connect(**conn_params) 
    File "/Library/Python/2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect 
    return Connection(*args, **kwargs) 
    File "/Library/Python/2.7/site-packages/MySQLdb/connections.py", line 193, in __init__ 
    super(Connection, self).__init__(*args, **kwargs2) 
django.db.utils.OperationalError: (1045, "Access denied for user 'abc'@'localhost' (using password: YES)") 
+3

閱讀您在設置中配置MySQL的用戶不允許訪問MySQL數據庫的最後一行 – timgeb

+0

。這是在最後一行用純文本寫的。 –

回答

0

這意味着用於連接到MySQL數據庫的連接字符串(在Django中是數據庫憑據)是錯誤的。在settings.py中檢查您的用戶名,密碼,主機,端口,數據庫名稱,並確保您的數據庫正在接受來自服務器的連接。