가장 간단한 방법은
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=[패스워드] mysql
사용 하는 방법인데
이번에는 우분투 환경에 mysql를 설치해볼 예정입니다.
우분투 실행
docker container run -d --privileged=true ubuntu sleep infinity
명령어를 통해 systemctl 과 mysql를 설치 해 줍니다.
apt install -y systemd mysql-server
명령어를 통해 mysql 실행
service mysql start
mysql 접속 및 사용자 추
root@d16ad900a5a2:/# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.35-0ubuntu0.22.04.1 (Ubuntu)
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> create user 'user'@'%'identified by '[비밀번호]';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on *.* TO 'user'@'%';
Query OK, 0 rows affected (0.00 sec)
완료
'인프라 > Docker' 카테고리의 다른 글
서버 이중화 테스트 환경 구축 (0) | 2024.01.12 |
---|---|
Docker를 통해 php + apache 개발 환경 구축 (0) | 2024.01.12 |
윈도우에서 docker in docker 사용 방법 (0) | 2023.09.02 |
k8s 실습을 위한 SpringBoot Dockerfile 작성 (0) | 2023.08.25 |
Ubuntu 환경에 Docker,Docker-compose 설치 및 sudo 권한 없이 사용하기 (0) | 2023.07.09 |