Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数据库初始化失败 #21

Closed
gogobody opened this issue May 17, 2021 · 7 comments · Fixed by #22
Closed

数据库初始化失败 #21

gogobody opened this issue May 17, 2021 · 7 comments · Fixed by #22

Comments

@gogobody
Copy link

数据库初始化失败, error: InternalError("(pymysql.err.InternalError) (1071, 'Specified key was too long; max key length is 767 bytes')")

Traceback (most recent call last):
  File "/www/workplace/omega-miya/omega_miya/utils/Omega_Base/database.py", line 45, in database_init
    await conn.run_sync(Base.metadata.create_all)
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/ext/asyncio/engine.py", line 472, in run_sync
    return await greenlet_spawn(fn, conn, *arg, **kw)
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 120, in greenlet_spawn
    result = context.throw(*sys.exc_info())
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 4744, in create_all
    bind._run_ddl_visitor(
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2081, in _run_ddl_visitor
    visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py", line 485, in traverse_single
    return meth(obj, **kw)
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 846, in visit_metadata
    self.traverse_single(
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py", line 485, in traverse_single
    return meth(obj, **kw)
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 902, in visit_table
    self.traverse_single(index, create_ok=True)
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py", line 485, in traverse_single
    return meth(obj, **kw)
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 933, in visit_index
    self.connection.execute(CreateIndex(index))
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/future/engine.py", line 280, in execute
    return self._execute_20(
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1582, in _execute_20
    return meth(self, args_10style, kwargs_10style, execution_options)
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 77, in _execute_on_connection
    return connection._execute_ddl(
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1352, in _execute_ddl
    ret = self._execute_context(
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1813, in _execute_context
    self._handle_dbapi_exception(
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1994, in _handle_dbapi_exception
    util.raise_(
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1770, in _execute_context
    self.dialect.do_execute(
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 717, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/aiomysql.py", line 95, in execute
    return self.await_(self._execute_async(operation, parameters))
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 62, in await_only
    return current.driver.switch(awaitable)
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 115, in greenlet_spawn
    value = await result
  File "/usr/local/python3/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/aiomysql.py", line 107, in _execute_async
    result = await self._cursor.execute(operation, parameters)
  File "/usr/local/python3/lib/python3.9/site-packages/aiomysql/cursors.py", line 239, in execute
    await self._query(query)
  File "/usr/local/python3/lib/python3.9/site-packages/aiomysql/cursors.py", line 457, in _query
    await conn.query(q)
  File "/usr/local/python3/lib/python3.9/site-packages/aiomysql/connection.py", line 428, in query
    await self._read_query_result(unbuffered=unbuffered)
  File "/usr/local/python3/lib/python3.9/site-packages/aiomysql/connection.py", line 622, in _read_query_result
    await result.read()
  File "/usr/local/python3/lib/python3.9/site-packages/aiomysql/connection.py", line 1105, in read
    first_packet = await self.connection._read_packet()
  File "/usr/local/python3/lib/python3.9/site-packages/aiomysql/connection.py", line 593, in _read_packet
    packet.check_error()
  File "/usr/local/python3/lib/python3.9/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/usr/local/python3/lib/python3.9/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1071, 'Specified key was too long; max key length is 767 bytes')
[SQL: CREATE UNIQUE INDEX ix_omega_pixiv_tag_tagname ON omega_pixiv_tag (tagname)]
(Background on this error at: http://sqlalche.me/e/14/2j85)

@gogobody
Copy link
Author

@Ailitonia
Copy link
Owner

没注意到mysql的系统变量问题😂
之后有空复现一下

@gogobody
Copy link
Author

没注意到mysql的系统变量问题😂
之后有空复现一下

请问下nonebot2 这个的PORT是如何配置的啊,我是根据nonebot2 和 go-cqhttp 官方,修改对应配置:

  ws_reverse_servers: [
    {
      enabled: true
      reverse_url: ws://127.0.0.1:3322/cqhttp/ws

但使用时,无法连接到反向socket

连接到反向WebSocket Universal服务器 ws://127.0.0.1:3322/cqhttp/ws 时出现错误: websocket: bad handshake

@Ailitonia
Copy link
Owner

solved see Specified key was too long; max key length is 767 bytes

的确是 innodb_large_prefix 参数的问题

不过我查了下文档, innodb_large_prefix 参数在 mysql 5.7 默认启用, 且为 Deprecated, 这个参数在 8.0 版本被废弃, 我感觉这个错误应该主要会出现在 5.7 之前的版本中

由于我使用 mysql 默认配置的原因之前倒是没有想到会出现这个问题, 之后会调整一下数据库表结构, 毕竟想想有的字段的确不需要那么长😂

@gogobody
Copy link
Author

solved see Specified key was too long; max key length is 767 bytes

的确是 innodb_large_prefix 参数的问题

不过我查了下文档, innodb_large_prefix 参数在 mysql 5.7 默认启用, 且为 Deprecated, 这个参数在 8.0 版本被废弃, 我感觉这个错误应该主要会出现在 5.7 之前的版本中

由于我使用 mysql 默认配置的原因之前倒是没有想到会出现这个问题, 之后会调整一下数据库表结构, 毕竟想想有的字段的确不需要那么长😂

确实,我的mysql 5.6

@Ailitonia
Copy link
Owner

没注意到mysql的系统变量问题😂
之后有空复现一下

请问下nonebot2 这个的PORT是如何配置的啊,我是根据nonebot2 和 go-cqhttp 官方,修改对应配置:

  ws_reverse_servers: [
    {
      enabled: true
      reverse_url: ws://127.0.0.1:3322/cqhttp/ws

但使用时,无法连接到反向socket

连接到反向WebSocket Universal服务器 ws://127.0.0.1:3322/cqhttp/ws 时出现错误: websocket: bad handshake

能提供 nb 和 gocq 完整的配置和日志吗

不过我觉得你可以先检查下 ACCESS_TOKEN 这个配置, 感觉可能两头的访问密钥没对上

@gogobody
Copy link
Author

检查确实是这个没对上,谢谢

@Ailitonia Ailitonia linked a pull request May 17, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants