Python框架之Django的数据库

在执行migrate的时候出现问题(错误见末尾)

django.db.utils.OperationalError: (1045, "Access denied for user ‘ODBC‘@‘localho

st‘ (using password: YES)")

 

Unhandled exception in thread started by <function check_errors.<locals>.wrapper

 at 0x031BD6F0>

Traceback (most recent call last):

  File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 

, in ensure_connection

    self.connect()

  File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 

, in connect

    self.connection = self.get_new_connection(conn_params)

  File "C:\Python36\lib\site-packages\django\db\backends\mysql\base.py", line 

, in get_new_connection

    conn = Database.connect(**conn_params)

  File "C:\Python36\lib\site-packages\MySQLdb\__init__.py", line , in Connect

    return Connection(*args, **kwargs)

  File "C:\Python36\lib\site-packages\MySQLdb\connections.py", line , in __in

it__

    super(Connection, self).__init__(*args, **kwargs2)

_mysql_exceptions.OperationalError: (, "Access denied for user ‘ODBC‘@‘local

host‘ (using password: YES)")

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

Traceback (most recent call last):

  File "C:\Python36\lib\site-packages\django\utils\autoreload.py", line , in

wrapper

    fn(*args, **kwargs)

  File "C:\Python36\lib\site-packages\django\core\management\commands\runserver.

py", line 125, in inner_run

    self.check(display_num_errors=True)

  File "C:\Python36\lib\site-packages\django\core\management\base.py", line ,

 in check

    include_deployment_checks=include_deployment_checks,

  File "C:\Python36\lib\site-packages\django\core\management\base.py", line ,

 in _run_checks

    return checks.run_checks(**kwargs)

  File "C:\Python36\lib\site-packages\django\core\checks\registry.py", line ,

in run_checks

    new_errors = check(app_configs=app_configs)

  File "C:\Python36\lib\site-packages\django\core\checks\model_checks.py", line

, in check_all_models

    errors.extend(model.check(**kwargs))

  File "C:\Python36\lib\site-packages\django\db\models\base.py", line , in c

heck

    errors.extend(cls._check_fields(**kwargs))

  File "C:\Python36\lib\site-packages\django\db\models\base.py", line , in _

check_fields

    errors.extend(field.check(**kwargs))

  File "C:\Python36\lib\site-packages\django\db\models\fields\__init__.py", line

 , in check

    errors = super(AutoField, self).check(**kwargs)

  File "C:\Python36\lib\site-packages\django\db\models\fields\__init__.py", line

 , in check

    errors.extend(self._check_backend_specific_checks(**kwargs))

  File "C:\Python36\lib\site-packages\django\db\models\fields\__init__.py", line

 , in _check_backend_specific_checks

    return connections[db].validation.check_field(self, **kwargs)

  File "C:\Python36\lib\site-packages\django\db\backends\mysql\validation.py", l

ine , in check_field

    field_type = field.db_type(self.connection)

  File "C:\Python36\lib\site-packages\django\db\models\fields\__init__.py", line

 , in db_type

    return connection.data_types[self.get_internal_type()] % data

  File "C:\Python36\lib\site-packages\django\utils\functional.py", line , in _

_get__

    res = instance.__dict__[self.name] = self.func(instance)

  File "C:\Python36\lib\site-packages\django\db\backends\mysql\base.py", line 

, in data_types

    if self.features.supports_microsecond_precision:

  File "C:\Python36\lib\site-packages\django\utils\functional.py", line , in _

_get__

    res = instance.__dict__[self.name] = self.func(instance)

  File "C:\Python36\lib\site-packages\django\db\backends\mysql\features.py", lin

e , in supports_microsecond_precision

    return self.connection.mysql_version >= (, , ) and Database.version_info

>= (, , )

  File "C:\Python36\lib\site-packages\django\utils\functional.py", line , in _

_get__

    res = instance.__dict__[self.name] = self.func(instance)

  File "C:\Python36\lib\site-packages\django\db\backends\mysql\base.py", line 

, in mysql_version

    with self.temporary_connection() as cursor:

  File "C:\Python36\lib\contextlib.py", line , in __enter__

    return next(self.gen)

  File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 

, in temporary_connection

    cursor = self.cursor()

  File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 

, in cursor

    return self._cursor()

  File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 

, in _cursor

    self.ensure_connection()

  File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 

, in ensure_connection

    self.connect()

  File "C:\Python36\lib\site-packages\django\db\utils.py", line , in __exit__

    six.reraise(dj_exc_type, dj_exc_value, traceback)

  File "C:\Python36\lib\site-packages\django\utils\six.py", line , in reraise

    raise value.with_traceback(tb)

  File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 

, in ensure_connection

    self.connect()

  File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 

, in connect

    self.connection = self.get_new_connection(conn_params)

  File "C:\Python36\lib\site-packages\django\db\backends\mysql\base.py", line 

, in get_new_connection

    conn = Database.connect(**conn_params)

  File "C:\Python36\lib\site-packages\MySQLdb\__init__.py", line , in Connect

    return Connection(*args, **kwargs)

  File "C:\Python36\lib\site-packages\MySQLdb\connections.py", line , in __in

it__

    super(Connection, self).__init__(*args, **kwargs2)

django.db.utils.OperationalError: (, "Access denied for user ‘ODBC‘@‘localho

st‘ (using password: YES)")

这里很奇怪为什么我配置的用户是 admin_py 怎么会显示 ‘ODBC’@‘localhost’?

有人说是账号密码错误,通过报错看来的和账号密码错误相关,但是手工去登陆mysql是OK的啊!

折腾了一会儿,仔细看官方文档配置:

DATABASES = {
‘default‘: {
‘ENGINE‘: ‘django.db.backends.postgresql‘,
‘NAME‘: ‘mydatabase‘,
‘USER‘: ‘mydatabaseuser‘,
‘PASSWORD‘: ‘mypassword‘,
‘HOST‘: ‘127.0.0.1‘,
‘PORT‘: ‘‘,
}}

我自己的配置:

DATABASES = {
‘default‘: {
‘ENGINE‘: ‘django.db.backends.mysql‘,
‘HOST‘: ‘127.0.0.1‘,
‘PORT‘: ,
‘NAME‘: ‘platform_admin_py‘,
‘USERNAME‘: ‘admin_py‘,
‘PASSWORD‘: ‘admin‘,
}
}

发现了没有?用户名的的那个KEY不对! 我承认我这是从网上看别人的配置写的,偷懒了,这就是代价

本文出自 “影子骑士” 博客:http://andylhz2009.blog.51cto.com/728703/1923552

在执行migrate的时候出现问题(错误见末尾): django.db.utils.OperationalError: (1045, "Access denied for user ‘ODBC‘@‘localho st‘ (using password: YES)")的更多相关文章

  1. 42.Pycharm连接数据库出现错误:1045、1044:django.db.utils.OperationalError: (1045, "Access denied for user 'Whois'@'localhost' (using password: YES)”)

    1.在pycharm中设置好数据库的连接信息,连接数据库db01, DATABASES = { 'default': { # 指定所使用的的数据库引擎 'ENGINE': 'django.db.bac ...

  2. django.db.utils.OperationalError: 1045错误

    django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using pass ...

  3. Django链接Mysql 8.0 出现错误(1045:Access denied for user 'root'@'localhost' (using password: NO) 的一种解决方法

    运行环境: Django版本2.0 ; Mysql 版本 8.0.11; 错误代码:  django.db.utils.OperationalError: (1045:Access denied fo ...

  4. CM使用MySQL数据库预处理scm_prepare_database.sh执行报错:java.sql.SQLException: Access denied for user 'scm'@'hadoop101.com' (using password: YES)

    1.报错提示: [root@hadoop101 ~]# /opt/module/cm/cm-/share/cmf/schema/scm_prepare_database.sh mysql cm -hh ...

  5. Win7环境下mysql报错1045:Access denied for user root@localhost错误解决方法

    产生场景:在涉及到连接数据库操作的时候,会报1045:Access denied for user root@localhost. 比如:本地建立的数据库连接不上,在IDEA等开发工具中使用反向生成. ...

  6. Navicat for Mysql远程连接数据时报(1045错误)Access denied for user 'root'@'localhost' (using password yes);

    原因:用户访问被拒绝,更改用户赋予密码即可 mysql命令行执行语句如下 //使用mysql,读取表信息 //更改用户赋予登录密码 //更新权限 注意点:使用flush privileges是为了刷新 ...

  7. 新安装XAMPP,phpMyAdmin错误:#1045 - Access denied for user 'root'@'localhost' (using password: NO)

    错误如下: 打开D:\Program Files\xampp\phpMyAdmin(你的xampp的安装目录下的phpMyAdmin目录)目录下的config.inc.php文件 将 改为 然后,错误 ...

  8. mysql ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)错误解决办法

    我的电脑是win10,所用的是mysql5.7.14 近期在学习mysql数据库的时候,遇到了这个错误,我的密码错误了.突如其来的问题,很是蒙蔽,因为我没对数据库设置过密码.通过网上查询,可以通过进入 ...

  9. MySql错误1045 Access denied for user 'root'@'localhost' (using password:YES) windows下的解决方案(忘记密码)

    1.进入管理员控制台停止mysql服务:net stop mysql; 2.进入mysql的安装路径,如我的安装路径为C:\Program Files\MySQL\MySQL Server 5.5,打 ...

随机推荐

  1. eclipse+cmake+c++11+ros

    eclipse+cmake: https://www.vtk.org/Wiki/CMake:Eclipse_UNIX_Tutorial eclipse+c++11: https://wiki.ecli ...

  2. Python3通过汉字输出拼音

    https://github.com/mozillazg/python-pinyin # pip install pypinyin from pypinyin import pinyin, lazy_ ...

  3. MS SQL Server迁移至Azure SQL

    SQL Server的数据目前是存在于公司服务器的,现时需要将它迁移至Azure SQL 迁移分两种 数据库结构复制 数据库结构复制与数据迁移至Azure SQL 第1种方法针对的是将现有数据库创建新 ...

  4. 转:x64与x86的改变

    http://tieba.baidu.com/p/1250470248 x64与x86的改变 硬件要求就是64位的CPU.操作系统也必须是64位的,如果在64位的CPU上安装了32位的操作系统,就算编 ...

  5. 只安装自己需要的Office2016组件的方法

    转自:https://www.ithome.com/html/office/178814.htm http://www.orsoon.com/news/184524.html

  6. CodeForces 733C Epidemic in Monstropolis

    模拟. 连续的一段$a$合成一个$b$.每段中如果数字只有$1$个,那么可以合成.如果数字个数大于等于$2$个,如果都是一样的,那么无法合成,否则要找到一个可以移动的最大值位置开始移动.一开始写了一个 ...

  7. python 理解高阶函数

    高阶函数 高阶函数英文叫Higher-order function.什么是高阶函数? 变量可以指向函数 以Python内置的求绝对值的函数abs()为例,调用abs(): >>> a ...

  8. UTF-8字符「EF BF BD」-备胎

    在众多的utf-8码点值中,除了ascii,你还应该记住「EF BF BD」,因为它是很多编程语言以及库中的备胎,即无效的码点值在编码的时候会默认用这个码点值进行替换,即utf-8中的超级「备胎」(R ...

  9. BestCoder Round #65 (ZYB's Game)

    ZYB's Game Accepts: 672 Submissions: 1207 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...

  10. PHP:根据二维数组中的某个字段进行排序

    首先了解下以下两个函数: 1.array_column() 返回输入数组中某个单一列的值. 2.array_multisort() 函数返回排序数组.您可以输入一个或多个数组.函数先对第一个数组进行排 ...