Cloud9からMySQLやPostgreSQLに接続する

Cloud9からAurora MySQLやAurora PostgreSQLに接続してバージョンを確認したメモ。

MySQL

mysqlクライアントはインストール済み。

接続する。SSL が必要な時は、--ssl を付与する。

ENDPOINT=<エンドポイント>
mysql -h ${ENDPOINT} -P 3306 -u admin -p

バージョンを確認する。

MySQL [(none)]> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 5.7.12    |
+-----------+
1 row in set (0.00 sec)

MySQL [(none)]> SELECT AURORA_VERSION();                                                                                                                                                                                       
+------------------+
| AURORA_VERSION() |
+------------------+
| 2.09.2           |
+------------------+
1 row in set (0.01 sec)

切断する。

MySQL [(none)]> exit
Bye

PostgreSQL

psqlをインストールする。

# sudo yum install postgresql
sudo amazon-linux-extras install -y postgresql14

なお、古いバージョンだと、接続時に psql: SCRAM authentication requires libpq version 10 or above というエラーになる。

接続する。

ENDPOINT=<エンドポイント>
psql -h ${ENDPOINT} -p 5432 -U postgres

バージョン確認する。

postgres=> SHOW SERVER_VERSION;
 server_version 
----------------
 11.9
(1 row)

postgres=> SELECT AURORA_VERSION();
 aurora_version 
----------------
 3.4.1
(1 row)

切断する。

postgres-> \q