[Python] django.db.utils.OperationalError: (1045:Access denied for user 'root'@'localhost'...

Discussão em 'Python' iniciado por Stack, Março 21, 2025.

  1. Stack

    Stack Membro Participativo

    After I installed Mysql 8.0 in mac, and changed the default root password, I got the error django.db.utils.OperationalError: (1045:Access denied for user 'root'@'localhost' (using password: NO) when I ran python3 manage.py migrate to connect MySql and init database tables, while I can login to mysql with root/new password in console without any error.

    • MySql version: 8.0 <-- the key to this problem actually
    • OS: macOS 10.13.4
    • Python: 3.6
    • Django: 1.10.3

    And it's using pymysql to work with Mysql, I did lots of google and also in stackorverflow, finally I found the solution in a CSDN tech blog

    Just want to share it in stackoverflow, if you also encountered this problem, you may want to try the way in the answer below.

    Continue reading...

Compartilhe esta Página