0
我無法遷移我的代碼。我在MySql中創建了一個數據庫和一個表,但是由於某種原因,我不得不卸載MySql,當我再次安裝它時,我將用戶名更改爲root。現在,它口口聲聲說無法同步數據庫
當我嘗試遷移(1045, 「訪問被拒絕的用戶 'djanu' @ 'localhost' 的(使用密碼:NO)」)
。當我第一次安裝它時,我將用戶命名爲djanu,並且我嘗試向用戶root授予權限,但同樣的消息不斷彈出。
這是我在settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'applics',
'USER': 'root',
'Password': '531010',
'HOST': '',
'PORT': '',
}
}
代碼和我的代碼,當我使用Python manage.py遷移,甚至的runserver
(myproject) C:\Users\home\myproject\collapp>python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\home\myproject\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "C:\Users\home\myproject\lib\site-packages\django\core\management\__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\home\myproject\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\home\myproject\lib\site-packages\django\core\management\base.py", line 342, in execute
self.check()
File "C:\Users\home\myproject\lib\site-packages\django\core\management\base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\home\myproject\lib\site-packages\django\core\management\commands\migrate.py", line 61, in _run_checks
issues = run_checks(tags=[Tags.database])
File "C:\Users\home\myproject\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\home\myproject\lib\site-packages\django\core\checks\database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "C:\Users\home\myproject\lib\site-packages\django\db\backends\mysql\validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "C:\Users\home\myproject\lib\site-packages\django\db\backends\mysql\validation.py", line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
File "C:\Users\home\myproject\lib\site-packages\django\db\backends\base\base.py", line 231, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "C:\Users\home\myproject\lib\site-packages\django\db\backends\base\base.py", line 204, in _cursor
self.ensure_connection()
File "C:\Users\home\myproject\lib\site-packages\django\db\backends\base\base.py", line 199, in ensure_connection
self.connect()
File "C:\Users\home\myproject\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\home\myproject\lib\site-packages\django\db\backends\base\base.py", line 199, in ensure_connection
self.connect()
File "C:\Users\home\myproject\lib\site-packages\django\db\backends\base\base.py", line 171, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\home\myproject\lib\site-packages\django\db\backends\mysql\base.py", line 263, in get_new_connection
conn = Database.connect(**conn_params)
File "C:\Users\home\myproject\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "C:\Users\home\myproject\lib\site-packages\MySQLdb\connections.py", line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1045, "Access denied for user 'djanu'@'localhost' (using password: NO)")
您在用戶設置中使用'USER':'root',''而不是'USER':'djanu'' –
請嘗試使用root用戶相同的方式 – Harsha
您的數據庫配置中也有不同的大小寫。確保它匹配文檔! –