Read Time:22 Second
MySQLコンテナに接続するためのコマンドは、docker exec
コマンドを使用します。
以下のコマンドを使用して、MySQLコンテナに接続できます。
>docker exec -it <コンテナ名> mysql -u <ユーザー名> -p
以下、試行例です。
1.コンテナの状態を確認する

2.MySQLコンテナに接続する
>docker exec -it mysql8.0.33-container mysql -u root -p

3.もし上記で接続できない(コマンドの反応がない)場合は、MySQLコンテナを再起動する
① 停止
>docker stop mysql8.0.33-container

② 再起動
>docker restart mysql8.0.33-container

③ 再度MySQLコンテナに接続する
>docker exec -it mysql8.0.33-container mysql -u root -p
