django 3.2, oceanbase版本是社区版4.2.1.4
我是用的是oceanbase的mysql租户,在连接数据库时报错信息是File “/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py”, line 33, in inner
return func(*args, **kwargs)
File “/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py”, line 259, in cursor
return self._cursor()
File “/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py”, line 235, in _cursor
self.ensure_connection()
File “/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py”, line 33, in inner
return func(*args, **kwargs)
File “/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py”, line 219, in ensure_connection
self.connect()
File “/usr/local/lib/python3.8/site-packages/django/db/utils.py”, line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File “/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py”, line 219, in ensure_connection
self.connect()
File “/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py”, line 33, in inner
return func(*args, **kwargs)
File “/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py”, line 200, in connect
self.connection = self.get_new_connection(conn_params)
File “/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py”, line 33, in inner
return func(*args, **kwargs)
File “/usr/local/lib/python3.8/site-packages/django/db/backends/mysql/base.py”, line 234, in get_new_connection
connection = Database.connect(**conn_params)
File “/usr/local/lib/python3.8/site-packages/pymysql/connections.py”, line 353, in init
self.connect()
File “/usr/local/lib/python3.8/site-packages/pymysql/connections.py”, line 641, in connect
c.execute(self.init_command)
File “/usr/local/lib/python3.8/site-packages/pymysql/cursors.py”, line 148, in execute
result = self._query(query)
File “/usr/local/lib/python3.8/site-packages/pymysql/cursors.py”, line 310, in _query
conn.query(q)
File “/usr/local/lib/python3.8/site-packages/pymysql/connections.py”, line 548, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/usr/local/lib/python3.8/site-packages/pymysql/connections.py”, line 775, in _read_query_result
result.read()
File “/usr/local/lib/python3.8/site-packages/pymysql/connections.py”, line 1156, in read
first_packet = self.connection._read_packet()
File “/usr/local/lib/python3.8/site-packages/pymysql/connections.py”, line 725, in _read_packet
packet.raise_for_error()
File “/usr/local/lib/python3.8/site-packages/pymysql/protocol.py”, line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File “/usr/local/lib/python3.8/site-packages/pymysql/err.py”, line 143, in raise_mysql_exception
raise errorclass(errno, errval)
django.db.utils.OperationalError: (5855, ‘parameter cannot be modified because specified value is invalid’)
配置如下,
这个是什么原因,应该如何修改呢
根据提供的错误信息,看起来是 OceanBase 的 MySQL 租户连接配置参数出现了问题,导致数据库连接失败。错误消息中的 (5855, 'parameter cannot be modified because specified value is invalid')
提示了一个参数无法被修改的错误。
看这个文档改改:default_storage_engine
修改成什么呢,InnoDB吗,我看文档只能是OceanBase啊,同时我SET GLOBAL default_storage_engine = ‘InnoDB’;
ERROR 5855 (HY000): parameter cannot be modified because specified value is invalid
我觉得你可以直接去掉OPTIONS这个参数呢,去掉应该可以正常连