Я пытаюсь настроить django в своей системе, и у меня возникла проблема с переносом бд с помощью xamp

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'djangomypro',
        'USER': 'root',
        'PASSWORD': '123456',
        'HOST': 'localhost',
        'PORT': ''
    }
}

Это моя конфигурация.

После запуска python manage.py migrate в терминале я получаю следующий результат.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "manage.py", line 15, in execute_from_command_line(sys.argv) File "/home/vishal/anaconda3/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/home/vishal/anaconda3/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/vishal/anaconda3/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv self.execute(*args, **cmd_options) File "/home/vishal/anaconda3/lib/python3.6/site-packages/django/core/management/base.py", line 350, in execute self.check() File "/home/vishal/anaconda3/lib/python3.6/site-packages/django/core/management/base.py", line 379, in check include_deployment_checks=include_deployment_checks, File "/home/vishal/anaconda3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 59, in _run_checks issues = run_checks(tags=[Tags.database]) File "/home/vishal/anaconda3/lib/python3.6/site-packages/django/core/checks/registry.py", line 71, in run_checks new_errors = check(app_configs=app_configs) File "/home/vishal/anaconda3/lib/python3.6/site-packages/django/core/checks/database.py", line 10, in check_database_backends issues.extend(conn.validation.check(**kwargs)) File "/home/vishal/anaconda3/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 9, in check issues.extend(self._check_sql_mode(**kwargs)) File "/home/vishal/anaconda3/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/vishal/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 255, in cursor return self._cursor() File "/home/vishal/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 232, in _cursor self.ensure_connection() File "/home/vishal/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection self.connect() File "/home/vishal/anaconda3/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/vishal/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection self.connect() File "/home/vishal/anaconda3/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/vishal/anaconda3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection return Database.connect(**conn_params) File "/home/vishal/anaconda3/lib/python3.6/site-packages/pymysql/init.py", line 94, in Connect return Connection(*args, **kwargs) File "/home/vishal/anaconda3/lib/python3.6/site-packages/pymysql/connections.py", line 327, in init self.connect() File "/home/vishal/anaconda3/lib/python3.6/site-packages/pymysql/connections.py", line 598, in connect self._request_authentication() File "/home/vishal/anaconda3/lib/python3.6/site-packages/pymysql/connections.py", line 862, in _request_authentication auth_packet = self._process_auth(plugin_name, auth_packet) File "/home/vishal/anaconda3/lib/python3.6/site-packages/pymysql/connections.py", line 933, in _process_auth pkt = self._read_packet() File "/home/vishal/anaconda3/lib/python3.6/site-packages/pymysql/connections.py", line 683, in _read_packet packet.check_error() File "/home/vishal/anaconda3/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error err.raise_mysql_exception(self._data) File "/home/vishal/anaconda3/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception raise errorclass(errno, errval) django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

1
0
834
1

Ответы 1

похоже, что django не может подключиться к вашей базе данных. Можете ли вы проверить, можете ли вы подключиться с помощью клиента базы данных. вы можете использовать MYSQLWorkbench, чтобы проверить это. попробуйте войти в систему с теми же параметрами, которые вы установили для django. Я не уверен, но вы должны увидеть, что mysql работает в вашем диспетчере задач.

вы также можете попробовать это:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'djangomypro',
        'USER': 'root',
        'PASSWORD': '123456',
        'HOST': 'localhost',
        'PORT': '3306'
    }
}

django.db.utils.OperationalError: (1045, «Доступ запрещен для пользователя 'root' @ 'localhost' (с использованием пароля: ДА)»)

django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
vishal pentakota 14.09.2018 17:41

Другие вопросы по теме