gpt4 book ai didi

mysql - 错误 1045 (28000) : Access denied for user 'root' @'localhost' error happens

转载 作者:行者123 更新时间:2023-11-29 07:30:42 25 4
gpt4 key购买 nike

当我在我的 Django 应用程序中运行 python manage.py migrate 时,发生如下错误

Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/core/management/base.py", line 327, in execute
self.check()
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 61, in _run_checks
issues = run_checks(tags=[Tags.database])
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/core/checks/database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "/home/vagrant/.pyenv/versions/3.6.3/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/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 254, in cursor
return self._cursor()
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 229, in _cursor
self.ensure_connection()
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 274, in get_new_connection
conn = Database.connect(**conn_params)
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pymysql/connections.py", line 327, in __init__
self.connect()
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pymysql/connections.py", line 598, in connect
self._request_authentication()
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pymysql/connections.py", line 862, in _request_authentication
auth_packet = self._process_auth(plugin_name, auth_packet)
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pymysql/connections.py", line 933, in _process_auth
pkt = self._read_packet()
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pymysql/connections.py", line 683, in _read_packet
packet.check_error()
File "/home/vagrant/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "/home/vagrant/.pyenv/versions/3.6.3/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 'admin'@'localhost' (using password: NO)")

我写了 mysql -u root,ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 当我运行服务时发生错误 mysqld start,无法启动 mysqld.service: Access denied error happens.Furthermore,when I run service mysql stop,Failed to stop mysql.service: Access denied error happen.I add sudo每个命令,但同样的错误发生。我真的不明白为什么会发生身份验证错误。我应该如何解决这个问题?我的代码有什么问题?

最佳答案

在较新的 MySQL 版本中,您还需要在命令中使用 -p 标志:

mysql -u root -p

然后输入密码就可以登录了。

Now you can create a new user as admin as you are using it with password and other permissions and can use in settings.py file.

关于mysql - 错误 1045 (28000) : Access denied for user 'root' @'localhost' error happens,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51413566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com