LoginSignup
0
0

More than 1 year has passed since last update.

MySQL Shell で AttributeError: unknown attribute: がでたときにはモードを疑う

Posted at

MySQL運用初心者です。
MySQL Shellを試している中で公式ドキュメントや書籍と異なる場面がでてきて、ネットで検索しても同様の事例がみつからずすこし困ったので、どなたかの助けになればと気付いたことを書いておきます。

環境

  • Ubuntu22.04
  • MySQL Server version: 8.0.31-0ubuntu0.22.04.1
  • MySQL Shell 8.0.23 (snap でインストールした。これが根本原因)

起きたこと

mysqlsh -u rootでログインし、レプリケーションの設定を試そうとすると以下のような実行結果となる。

mysql-py []> dba.configureReplicaSetInstance()
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: unknown attribute: configureReplicaSetInstance

公式ドキュメントでは、同じコマンドなのになぜだろう(よくみるとJSかPyかが違う)

いろいろ参考にしていてたいへん有用なこの書籍 MySQL徹底入門 第4版 でもこのコマンドで特に注釈はない。

原因

Pyモードだからっぽい。ヘルプをみると下記のようにスネークケースのコマンドがでてきた

>\? dba
()
configure_replica_set_instance([instance][, options])
    Validates and configures an instance for use in an InnoDB
            ReplicaSet.
()

というわけでこれで動作します。

mysql-py []> dba.configure_replica_set_instance()

ちなみに公式ドキュメントだと \js でjsモードに変更できるとあるが、手元の環境では Unknown command になるし、\? でもそんなコマンドはなさそうだった。

調べると、snapでインストールしているとjsモードはないらしい・・・。バージョン難しいよ~
https://dba.stackexchange.com/questions/302402/how-to-start-mysql-shell-in-mysql-js-javascript-mode

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0