0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RedHat Enterprise LinuxのMySQLコンテナを実行する

Posted at

実行環境

  • Fedora Server
  • Podman

ログイン

初回のみregistry.redhat.comにログインする

[master@fedora ~]$ podman login registry.redhat.io
Username: [username]
Password: [password]
Login Succeeded!

Mysql 8.0のコンテナを実行する

[master@fedora ~]$ podman run --name mysql-custom  -e MYSQL_USER=mysql -e MYSQL_PASSWORD=password  -e MYSQL_ROOT_PASSWORD=password  -d registry.redhat.io/rhel8/mysql-80

Trying to pull registry.redhat.io/rhel8/mysql-80:latest...
Getting image source signatures
Copying blob 06038631a24a skipped: already exists
Copying blob 262268b65bd5 skipped: already exists
Copying blob 44115d860fce skipped: already exists
Copying blob e6407044eff6 done
Copying config 09887d80b9 done
Writing manifest to image destination
Storing signatures
97522dd5e18d163ee9fc17dbaac64474b0989988d9b5c67d77acd17dac79d954

未ログインの場合

registry.redhat.ioに未ログインの場合、以下のように表示される。

podman run --name mysql-custom  -e MYSQL_USER=mysql -e MYSQL_PASSWORD=password  -e MYSQL_ROOT_PASSWORD=password  -d registry.redhat.io/rhel8/mysql-80
Trying to pull registry.redhat.io/rhel8/mysql-80:latest...
Error: Error initializing source docker://registry.redhat.io/rhel8/mysql-80:latest: unable to retrieve auth token: invalid username/password: unauthorized: Please login to the Red Hat Registry using your Customer Portal credentials. Further instructions can be found here: https://access.redhat.com/RegistryAuthentication

コンテナ内でシェル実行

コンテナ内でシェルを実行する

[master@fedora ~]$ podman exec -it mysql-custom /bin/bash
bash-4.4$

データベースにログインする

bash-4.4$ mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

データベースを作成する

mysql> create database items;
Query OK, 1 row affected (0.44 sec)

データベースを確認する

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| items              |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

使用するデータベースを選択する

mysql> use items;
Database changed

終了する

mysql> exit
Bye
bash-4.2$ exit
exit
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?