状況
DockerのMySQLのコンテナ内にて以下のように実行したところ表題のエラーが発生しました。
$ mysql> show tables;
ERROR 1046 (3D000): No database selected
解消法
以下のコマンドで使用するデータベースを選択したところ解消しました。
$ mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| sample |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
$ mysql> use sample
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
$ mysql> show tables;
+-------------------------+
| Tables_in_sample |
+-------------------------+
| ar_internal_metadata |
| samples |
| schema_migrations |
+-------------------------+
3 rows in set (0.01 sec)