我正试图将我的应用程序与Cpanel托管平台上的MySQL数据库引擎连接,但每次我尝试运行makemigrations
时,总是会出现这样的长错误:
Traceback (most recent call last):
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 244, in ensure_connection
self.connect()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 225, in connect
self.connection = self.get_new_connection(conn_params)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/django/base.py", line 366, in get_new_connection
cnx = mysql.connector.connect(**conn_params)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/pooling.py", line 286, in connect
return CMySQLConnection(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/connection_cext.py", line 101, in __init__
self.connect(**kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1099, in connect
self._post_connection()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1071, in _post_connection
self.set_charset_collation(self._charset_id)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1016, in set_charset_collation
) = CharacterSet.get_charset_info(charset)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/constants.py", line 775, in get_charset_info
info = cls.get_default_collation(charset)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/constants.py", line 746, in get_default_collation
raise ProgrammingError(f"Character set '{charset}' unsupported")
mysql.connector.errors.ProgrammingError: Character set '255' unsupported
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home2/cmsmcsc1/cmsmcs/manage.py", line 22, in <module>
main()
File "/home2/cmsmcsc1/cmsmcs/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/base.py", line 460, in execute
output = self.handle(*args, **options)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/base.py", line 98, in wrapped
res = handle_func(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/core/management/commands/makemigrations.py", line 119, in handle
loader.check_consistent_history(connection)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/migrations/loader.py", line 313, in check_consistent_history
applied = recorder.applied_migrations()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 81, in applied_migrations
if self.has_table():
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 57, in has_table
with self.connection.cursor() as cursor:
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 284, in cursor
return self._cursor()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 260, in _cursor
self.ensure_connection()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 244, in ensure_connection
self.connect()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 244, in ensure_connection
self.connect()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib/python3.9/site-packages/django/db/backends/base/base.py", line 225, in connect
self.connection = self.get_new_connection(conn_params)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/django/base.py", line 366, in get_new_connection
cnx = mysql.connector.connect(**conn_params)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/pooling.py", line 286, in connect
return CMySQLConnection(*args, **kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/connection_cext.py", line 101, in __init__
self.connect(**kwargs)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1099, in connect
self._post_connection()
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1071, in _post_connection
self.set_charset_collation(self._charset_id)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/abstracts.py", line 1016, in set_charset_collation
) = CharacterSet.get_charset_info(charset)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/constants.py", line 775, in get_charset_info
info = cls.get_default_collation(charset)
File "/home2/cmsmcsc1/virtualenv/cmsmcs/3.9/lib64/python3.9/site-packages/mysql/connector/constants.py", line 746, in get_default_collation
raise ProgrammingError(f"Character set '{charset}' unsupported")
django.db.utils.ProgrammingError: (-1, "Character set '255' unsupported", None)
有人知道该怎么办吗?
试试看,它肯定会帮助你
在您的Cpanel主机终端中运行该命令
pip3 install mysql-connector-python==8.0.29