当我使用slqalchemy连接到mysql数据库时,出现错误,并显示无法加载uft8mb4。我的答案是我要修改文件“ / user / share / mysql / charsets”。我发现我没有此文件夹。我想是因为当其他人安装mysql时,mysql的默认位置已更改。
我已经修改了'/etc/mysql/mysql.cnf' 文件中的默认编码。 然后重新启动服务,但仍然不能
File "/usr/python/lib/python2.7/site-packages/django/db/backends/__init__.py", line 115, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/python/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 435, in get_new_connection
conn = Database.connect(**conn_params)
File "/usr/python/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/python/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/MySQLdb/connections.py", line 221, in __init__
self.set_character_set(charset)
File "/usr/python/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/MySQLdb/connections.py", line 312, in set_character_set
super(Connection, self).set_character_set(charset)
OperationalError: (2019, "Can't initialize character set utf8mb4 (path: /usr/share/mysql/charsets/)")