(1193,“未知系统变量'explicit\u defaults\u for \u timestamp'”)[sql:'select@@explicit\u defaults\u for \u timestamp']

ki1q1bka  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(352)

在虚拟环境中运行此shell时:

airflow initdb

它的轨迹:

Traceback (most recent call last):
  File "/usr/bin/airflow", line 28, in <module>
    args.func(args)
  File "/usr/lib/python2.7/site-packages/airflow/bin/cli.py", line 1002, in initdb
    db_utils.initdb(settings.RBAC)
  File "/usr/lib/python2.7/site-packages/airflow/utils/db.py", line 92, in initdb
    upgradedb()
  File "/usr/lib/python2.7/site-packages/airflow/utils/db.py", line 346, in upgradedb
    command.upgrade(config, 'heads')
  File "/usr/lib/python2.7/site-packages/alembic/command.py", line 174, in upgrade
    script.run_env()
  File "/usr/lib/python2.7/site-packages/alembic/script/base.py", line 416, in run_env
    util.load_python_file(self.dir, 'env.py')
  File "/usr/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
    module = load_module_py(module_id, path)
  File "/usr/lib/python2.7/site-packages/alembic/util/compat.py", line 79, in load_module_py
    mod = imp.load_source(module_id, path, fp)
  File "/usr/lib/python2.7/site-packages/airflow/migrations/env.py", line 91, in <module>
    run_migrations_online()
  File "/usr/lib/python2.7/site-packages/airflow/migrations/env.py", line 86, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/usr/lib/python2.7/site-packages/alembic/runtime/environment.py", line 807, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/usr/lib/python2.7/site-packages/alembic/runtime/migration.py", line 321, in run_migrations
    step.migration_fn(**kw)
  File "/usr/lib/python2.7/site-packages/airflow/migrations/versions/0e2a74e0fc9f_add_time_zone_awareness.py", line 43, in upgrade
    cur = conn.execute("SELECT @@explicit_defaults_for_timestamp")
  File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 939, in execute
    return self._execute_text(object, multiparams, params)
  File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1097, in _execute_text
    statement, parameters
  File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
    exc_info
  File "/usr/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1193, "Unknown system variable 'explicit_defaults_for_timestamp'") [SQL: 'SELECT @@explicit_defaults_for_timestamp']

mysql是在centos7上运行的,它有数据库气流。我已经修改了sql\炼金术连接。我怎么了?期待您的回复。谢谢。

kknvjkwl

kknvjkwl1#

看起来你没有系统变量 explicit_defaults_for_timestamp 在系统变量中。
检查数据库版本以查看是否支持此变量(mariadb>=10.1.8)
将此行添加到 my.cnf [mysqld]下的文件 explicit_defaults_for_timestamp = 1 您也可以参考以下答案:
https://stackoverflow.com/a/15896461/8186183

相关问题