【问题标题】:Can I connect to Tarantool with mysql or psql console?我可以使用 mysql 或 psql 控制台连接到 Tarantool 吗?
【发布时间】:2020-07-16 11:06:39
【问题描述】:

我发现我可以执行 SQL 请求,但只能在 Tarantool 内部执行。

我能否像在 MySQL shell 或 Postgres shell 中那样连接到 Tarantool?

mysql -u admin -h localhost -P 3301
# or
psql ...

或者如何配置其他只能理解 MySQL 或 Postgres 连接的程序来使用 Tarantool?

【问题讨论】:

    标签: tarantool


    【解决方案1】:

    您不能使用mysqlpsql 控制台命令连接到 Tarantool,因为每个服务器的通信协议不同。出于同样的原因,例如,您无法使用 mysql 实用程序连接到 Posgres。但是,没有什么可以阻止您使用tarantoolctl 对 Tarantool 执行 SQL 请求。一旦附加到实例(使用tarantoolctl enter my_instancetarantoolctl connect <uri>),您可以将默认语言从 Lua 切换到 SQL:

    \set language sql
    \set delimiter ;
    

    之后就可以直接在控制台执行SQL语句了。

    作为记录,也可以使用Lua functions 执行 SQL,但这似乎不太方便:

    box.execute([[ SELECT 1, 2, 3 ]])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-20
      • 1970-01-01
      • 1970-01-01
      • 2010-10-25
      • 2022-11-14
      • 2016-02-03
      相关资源
      最近更新 更多