zoukankan      html  css  js  c++  java
  • python3.5+Django2.2+pymysql+mysql

    1,在project同名文件夹下的__init__文件中添加如下代码即可

    import pymysql
    pymysql.install_as_MySQLdb(),

    2,修改setting文件

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'test2',
            'USER':'root',
            'PASSWORD':'Gauss_234',
            'HOST':'139.155.131.188',
            'POST':'3306',
        }
    }

    3,mysql授权

    grant     all privileges    on test2.*    to 'root'@'139.155.131.188' identified "password" with  grant option;
    flush privileges;

    4,如果这时候启动django会报错

    django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

    修改Python35Libsite-packagesdjangodbackendsmysqlase.py

    打开后将如下代码注释:

     注释好了之后重新启动django服务器:

    会出现以下报错信息、

    AttributeError: 'str' object has no attribute 'decode'

    找到python文件下的django文件>db文件>backends>mysql>operations.py

    将decode修改为encode

     最后重启服务即可

    参考链接:http://www.pianshen.com/article/2285376009/

  • 相关阅读:
    适配器
    装饰器
    getOwnPropertyDescriptor
    发布订阅
    策略模式
    window.requestAnimationFrame() 和 window.cancelAnimationFrame()
    L1-056 猜数字
    L1-055 谁是赢家
    L1-054 福到了
    L1-053 电子汪
  • 原文地址:https://www.cnblogs.com/wzy23/p/11612712.html
Copyright © 2011-2022 走看看