Ready to start the Python environment, with the Django framework whose default database is Sqlite3, to use MySQL to store the data
A problem occurred while executing the migrate (see the end of the error):
Unhandled exception in thread started by <function Check_errors.<locals>.wrapper
At 0x031bd6f0>
Traceback (most recent):
File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 213
, in Ensure_connection
Self.connect ()
File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 189
, in Connect
Self.connection = Self.get_new_connection (conn_params)
File "C:\Python36\lib\site-packages\django\db\backends\mysql\base.py", line 27
4, 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 204, in __in
it__
Super (Connection, self). __init__ (*args, **KWARGS2)
_mysql_exceptions. Operationalerror: (1045, "Access denied for user ' ODBC ' @ ' Local
Host ' (using Password:yes))
The above exception was the direct cause of the following exception:
Traceback (most recent):
File "C:\Python36\lib\site-packages\django\utils\autoreload.py", line 227, in
Wrapper
FN (*args, **kwargs)
File "C:\Python36\lib\site-packages\django\core\management\commands\runserver.
Py ", line A, in Inner_run
Self.check (Display_num_errors=true)
File "C:\Python36\lib\site-packages\django\core\management\base.py", line 359,
In check
Include_deployment_checks=include_deployment_checks,
File "C:\Python36\lib\site-packages\django\core\management\base.py", line 346,
In _run_checks
Return Checks.run_checks (**kwargs)
File "C:\Python36\lib\site-packages\django\core\checks\registry.py", line 81,
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 1282, in C
Heck
Errors.extend (Cls._check_fields (**kwargs))
File "C:\Python36\lib\site-packages\django\db\models\base.py", line 1357, in _
Check_fields
Errors.extend (Field.check (**kwargs))
File "C:\Python36\lib\site-packages\django\db\models\fields\__init__.py", line
909, in check
Errors = Super (Autofield, self). Check (**kwargs)
File "C:\Python36\lib\site-packages\django\db\models\fields\__init__.py", line
219, in check
Errors.extend (Self._check_backend_specific_checks (**kwargs))
File "C:\Python36\lib\site-packages\django\db\models\fields\__init__.py", line
322, 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
640, 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 17
4, 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 >= (5, 6, 4) and Database.version_info
>= (1, 2, 5)
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 38
5, in Mysql_version
With Self.temporary_connection () as cursor:
File "C:\Python36\lib\contextlib.py", line-__enter__, in
Return Next (Self.gen)
File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 591
, in Temporary_connection
cursor = Self.cursor ()
File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 254
, in cursor
Return Self._cursor ()
File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 229
, in _cursor
Self.ensure_connection ()
File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 213
, in Ensure_connection
Self.connect ()
File "C:\Python36\lib\site-packages\django\db\utils.py", line 94, in __exit__
Six.reraise (Dj_exc_type, Dj_exc_value, Traceback)
File "C:\Python36\lib\site-packages\django\utils\six.py", line 685, in Reraise
Raise Value.with_traceback (TB)
File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 213
, in Ensure_connection
Self.connect ()
File "C:\Python36\lib\site-packages\django\db\backends\base\base.py", line 189
, in Connect
Self.connection = Self.get_new_connection (conn_params)
File "C:\Python36\lib\site-packages\django\db\backends\mysql\base.py", line 27
4, 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 204, in __in
it__
Super (Connection, self). __init__ (*args, **KWARGS2)
Django.db.utils.OperationalError: (1045, "Access denied for user ' ODBC ' @ ' Localho
St ' (using Password:yes) ")
It's strange here why the user I configured is admin_py how does it show ' ODBC ' @ ' localhost '?
Some people say is the account password error, through the error appears and account password errors related, but manually to log on to MySQL is OK Ah!
Toss for a moment and look carefully at the Official document configuration:
DATABASES = {' default ': {' ENGINE ': ' Django.db.backends.postgresql ', ' NAME ': ' MyDatabase ', ' USER ' : ' Mydatabaseuser ', ' PASSWORD ': ' MyPassword ', ' HOST ': ' 127.0.0.1 ', ' PORT ': ' 5432 ',}}
My own configuration:
DATABASES = {' default ': {' ENGINE ': ' Django.db.backends.mysql ', ' HOST ': ' 127.0.0.1 ', ' PORT ': 3306 , ' NAME ': ' platform_admin_py ', ' USERNAME ': ' admin_py ', ' PASSWORD ': ' Admin ',}}
Did you find it? The key to the user name is not right! I admit that I read it from the internet, I'm lazy, that's the price.
This article is from "Shadow Knight" blog, please make sure to keep this source http://andylhz2009.blog.51cto.com/728703/1923552
The Python framework's Django database configuration problem