티스토리 뷰

OS/Orange PI

Orange Pi 5 : Docker - MySQL 설치

파란크리스마스 2023. 1. 23. 15:43
728x90

출처

리눅스 확인

orangepi@orangepi5:~$ uname -a
Linux orangepi5 5.10.110-rockchip-rk3588 #1.1.0 SMP Fri Jan 6 14:00:53 CST 2023 aarch64 aarch64 aarch64 GNU/Linux
orangepi@orangepi5:~$ cat /proc/version
Linux version 5.10.110-rockchip-rk3588 (root@test) (aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025, GNU ld (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 2.33.1.20191209) #1.1.0 SMP Fri Jan 6 14:00:53 CST 2023
orangepi@orangepi5:~$ uname -r
5.10.110-rockchip-rk3588
orangepi@orangepi5:~$ uname -m 
aarch64
orangepi@orangepi5:~$ cat /etc/issue
Orange Pi 1.1.0 Jammy \l 
 
orangepi@orangepi5:~$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"
## PLEASE DO NOT EDIT THIS FILE
BOARD=orangepi5
BOARD_NAME="Orange Pi 5"
BOARDFAMILY=rockchip-rk3588
BUILD_REPOSITORY_URL=https://github.com/orangepi-xunlong/orangepi-build
BUILD_REPOSITORY_COMMIT=1e88c5d82-dirty
DISTRIBUTION_CODENAME=jammy
DISTRIBUTION_STATUS=supported
VERSION=1.1.0
LINUXFAMILY=rockchip-rk3588
ARCH=arm64
IMAGE_TYPE=user-built
BOARD_TYPE=conf
INITRD_ARCH=arm64
KERNEL_IMAGE_TYPE=Image
IMAGE_UUID=7307ac30-03ec-42b9-ac3a-10244aa27a85
## PLEASE DO NOT EDIT THIS FILE
BOARD=orangepi5
BOARD_NAME="Orange Pi 5"
BOARDFAMILY=rockchip-rk3588
BUILD_REPOSITORY_URL=https://github.com/orangepi-xunlong/orangepi-build
BUILD_REPOSITORY_COMMIT=1e88c5d82-dirty
DISTRIBUTION_CODENAME=jammy
DISTRIBUTION_STATUS=supported
VERSION=1.1.0
LINUXFAMILY=rockchip-rk3588
ARCH=arm64
IMAGE_TYPE=user-built
BOARD_TYPE=conf
INITRD_ARCH=arm64
KERNEL_IMAGE_TYPE=Image
BRANCH=legacy
PRETTY_NAME="Orange Pi 1.1.0 Jammy"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

도커 버전 확인

orangepi@orangepi5:~$ docker version
Client: Docker Engine - Community
 Version:           20.10.23
 API version:       1.41
 Go version:        go1.18.10
 Git commit:        7155243
 Built:             Thu Jan 19 17:33:18 2023
 OS/Arch:           linux/arm64
 Context:           default
 Experimental:      true
 
Server: Docker Engine - Community
 Engine:
  Version:          20.10.23
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.10
  Git commit:       6051f14
  Built:            Thu Jan 19 17:31:30 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.15
  GitCommit:        5b842e528e99d4d4c1686467debf2bd4b88ecd86
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

mysql 이미지 받아오기 (pull)

orangepi@orangepi3b:~$ docker pull mysql/mysql-server:5.7
5.7: Pulling from mysql/mysql-server
d70f3c0cccba: Pull complete 
e7dc89aa39f7: Pull complete 
76cc4215b650: Pull complete 
25b0bb53e492: Pull complete 
349b52643cc3: Pull complete 
62ddcf4a4134: Pull complete 
c91c597e717d: Pull complete 
c7e93886e496: Pull complete 
Digest: sha256:1178cdd375f758968cd834ac4057bae41307e64b7c69a9e145896e7b11f48064
Status: Downloaded newer image for mysql/mysql-server:5.7
docker.io/mysql/mysql-server:5.7

mysql 도커 이미지 실행 (브릿지모드)

orangepi@orangepi5:~$ docker run -d \
  -p 3306:3306 \
  -e MYSQL_ROOT_PASSWORD=password \
  --name mysql-server \
  -v /exthdd/dockerData/mysql:/var/lib/mysql mysql/mysql-server:latest \
  --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
b51f212af1a497b5ac6de8c5cdccd7ba4f0e40390eb7e036806a9464c27553f9

mysql 실행 확인

orangepi@orangepi5:~$ docker ps -a
CONTAINER ID   IMAGE                       COMMAND                  CREATED              STATUS                        PORTS                                                        NAMES
b51f212af1a4   mysql/mysql-server:latest   "/entrypoint.sh --ch…"   About a minute ago   Up About a minute (healthy)   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060-33061/tcp   mysql-server

MySQL 접속, root 외부 접속 계정 생성

Docker로 mysql-server 컨테이너 접속

orangepi@orangepi5:~$ docker exec -it mysql-server /bin/bash
bash-4.4# whoami
root

MySQL 접속

bash-4.4# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.32 MySQL Community Server - GPL
 
Copyright (c) 2000, 2023, 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 데이터베이스로 이동

mysql> use mysql;
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> select host, user, authentication_string from user;
+-----------+------------------+------------------------------------------------------------------------+
| host      | user             | authentication_string                                                  |
+-----------+------------------+------------------------------------------------------------------------+
| localhost | healthchecker    | $A$005$+o%8u   V&V5A01J/aCWOrIjMG.NNcTxQAqUkzIu9vZanJ07NooGg1O45EbB |
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session    | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys        | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root             | $A$005$6wQait7{        _\4vz,0OhQhCJkeGInRJt8/bv2BUvcnAj/izDj.00Zuob8458 |
+-----------+------------------+------------------------------------------------------------------------+
5 rows in set (0.00 sec)

외부 접속이 가능한 root 계정 생성

mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.06 sec)
 
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.04 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

생성된 root 계정 확인

mysql> select host, user, authentication_string from user;
+-----------+------------------+------------------------------------------------------------------------+
| host      | user             | authentication_string                                                  |
+-----------+------------------+------------------------------------------------------------------------+
| %         | root             | $A$005$s%:wO_,UA0W%f+BtL6iODgWvpDzbLfAxYRM169ckvJPVwgjc79mxY7LKK4 |
| localhost | healthchecker    | $A$005$+o%8u   V&V5A01J/aCWOrIjMG.NNcTxQAqUkzIu9vZanJ07NooGg1O45EbB |
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session    | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys        | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root             | $A$005$6wQait7{        _\4vz,0OhQhCJkeGInRJt8/bv2BUvcnAj/izDj.00Zuob8458 |
+-----------+------------------+------------------------------------------------------------------------+
6 rows in set (0.00 sec)

MySQL 포트 확인

orangepi@orangepi5:~$ netstat -nao | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      off (0.00/0/0)
tcp6       0      0 :::3306                 :::*                    LISTEN      off (0.00/0/0)
unix  3      [ ]         STREAM     CONNECTED     33067    /run/user/1000/bus
unix  3      [ ]         STREAM     CONNECTED     33065    /run/user/1000/bus
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함