django执行python manage.py makemigrations时报Access denied for user 'root'@'localhost'

在执行Django的`python manage.py makemigrations`时遇到'Access denied for user 'root'@'localhost'错误。经过排查,不是用户名或密码错误,而是需要更改MySQL的root密码,并通过`makemigrations --empty`初始化空迁移,然后正常执行`makemigrations`和`migrate`。完成操作后虽然问题解决,但出现新疑问:是否root密码不能设置为'mysql'。
摘要由CSDN通过智能技术生成

django执行python manage.py makemigrations时报Access denied for user 'root'@'localhost',搞了我整整两晚上,终于解决了!!!

报错如下 :

E:\pythonStudy\myPythonProject\django180513\project>python manage.py makemigrations

Traceback (most recent call last):
  File "C:\Users\E570\Anaconda3\Lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
  File "C:\Users\E570\Anaconda3\Lib\site-packages\django\db\backends\base\base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\E570\Anaconda3\Lib\site-packages\django\db\backends\mysql\base.py", line 274, in get_new_connection
    conn = Database.connect(**conn_params)
  File "C:\Users\E570\Anaconda3\Lib\site-packages\pymysql\__init__.py", line 90, in Connect
    return Connection(*args, **kwargs)
  File "C:\Users\E570\Anaconda3\Lib\site-packages\pymysql\connections.py", line 704, in __init__
    self.connect()
  File "C:\Users\E570\Anaconda3\Lib\site-packages\pymysql\connections.py", line 974, in connect
    self._request_authentication()
  File "C:\Users\E570\Anaconda3\Lib\site-packages\pymysql\connections.py", line 1203, in _request_authentication
    auth_packet = self._read_packet()
  File "C:\Users\E570\Anaconda3\Lib\site-packages\pymysql\connections.py", line 1059, in _read_packet
    packet.check_error()
  File "C:\Users\E570\Anaconda3\Lib\site-packages\pymysql\connections.py", line 384, in check_error
    err.raise_mysql_exception(self._data)
  File "C:\Users\E570\Anaconda3\Lib\site-packages\pymysql\err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")


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


Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\E570\Anaconda3\Lib\site-packages\django\core\management\__init__.py", line 363, in execute_from
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值