Django2.2 mySQL database connection

A, Django2.2 connect to the database (step on mine)

  First, Django2.2 comes with a sqlite3 database, but we learned about mysql, therefore learn to connect ( in the environment to build mysql case of success ) --- Reference blog:

  https://blog.csdn.net/qq_20788055/article/details/80372577

  1.1 mysql data into the control bar (because mysql password is required, can not directly create)

  mysql-uroot-p password (my presence here so show could not be created) - Creating a database

  

 

  Then fill out the appropriate application user and password --- according to library just created in order to pycharm

  

 

 

 

 

 

   1.2 to perform database migration command makemigrations

    python manage.py makemigrations

    Will complain that there is no mysql client - but I have, so import package

    pip install pymysql ( in fact there are many similar packages, but pymysql ---- support python2, python3 ------ can also masquerade as a client mysql )

    

 

 

   1.3 migration is performed again, and the error ---- panic, version compatibility issues

  

 

 

 

     1.4 python change profile ******* \ Lib \ site-packages \ django \ db \ backends \ mysql \ base.py file and

    lib\site-packages\django\db\backends\mysql\operations.py文件

    

 

 

 -------base.py

----- originally changed to encode to decode ----

 

 

  1.5 and then perform the migration --------- success, mysql and own client database software sync

 

 

 

 

 

 

 

 

  -----------有兴趣的伙伴,欢迎一起学习交流,希望对你们有用

    

 

 

 

  

Guess you like

Origin www.cnblogs.com/cybg/p/11906652.html