Ubuntu MySQL 8.0.26 수동 설치 (지정 폴더 설치) 다운로드 경로 포함
신규로 배포되어야 하는 프로젝트가 있어 서버 정보를 전달받았는데 서버로 담당자도 어떤 프로그램이 돌아가고 있는지 잘 모르는 상태여서 최대한 기존 서비스는 건드리지 않고 진행하기 위해 수동 설치를 진행해보려고 합니다.
저는 기존 서버 환경을 최대한 안거 드리기 위해 명령어를 최소한으로 실행하였기 때문에 같은 작업이 필요하신 분은 바로 따라 하지 마시고 글을 끝까지 읽어보신 후 작업하시는 것을 추천드립니다.
작업환경 : Ubuntu 18.04.6 64bit
1. 작업 폴더 생성 후 이동
mkdir /data/app
cd /data/app
2. Mysql 8.0.26 tar 파일 다운로드
mysql 공식 홈페이지에서 링크를 추출하여 진행합니다.
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.26.tar.gz
다른 버전은 아래 링크에서 확인 가능합니다.
https://downloads.mysql.com/archives/community/
MySQL :: Download MySQL Community Server (Archived Versions)
Please note that these are old versions. New releases will have recent bug fixes and features! To download the latest release of MySQL Community Server, please visit MySQL Downloads. MySQL open source software is provided under the GPL License.
downloads.mysql.com
3. tar 압축 해제
tar xvfz mysql-8.0.26.tar.gz
4. mysql-8.0.26 폴더 이동
cd mysql-8.0.26
5. 임시 폴더 생성
mysql을 패키징해야되기 때문에 임시 폴더가 필요합니다. 폴더명은 아무거나 상관없습니다.
mkdir mysqldir
6. 디렉토리 이동
cd mysqldir
7. CMAKE 실행
cmake \
.. \
-DCMAKE_INSTALL_PREFIX=/data/app/mysql \
-DMYSQL_DATADIR=/data/app/mysql/data \
-DMYSQL_UNIX_ADDR=/data/app/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3308 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DSYSCONFDIR=/data/app \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/data/app/mysql/boost
make
make test
make install
cmake는 ..을 기준으로 실행합니다.
CMAKE는 유효성 검사를 자동으로 해주기 때문에 시간도 많이 소요되고 용량도 많이 필요합니다.
완료되었을 때 2시간 정도 소요되었고 21GB 정도 저장공간을 사용하였습ㄴ비다.
7-1 오류 발생
CMake Deprecation Warning at cmake/cmake_policies.cmake:59 (CMAKE_POLICY):
The OLD behavior for policy CMP0073 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
CMakeLists.txt:234 (INCLUDE)
-- Looking for gcc-8 on Ubuntu 18.04
CMake Warning at CMakeLists.txt:333 (MESSAGE):
Could not find gcc-8
CMake Error at CMakeLists.txt:334 (MESSAGE):
Please do 'apt install gcc-8 g++-8'
or set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER explicitly.
-- Configuring incomplete, errors occurred!
7-2 gcc-8 g++-8 패키지 설치
apt install gcc-8 g++-8
아래 패키지들은 확인 후 없는 것만 설치하시면 됩니다.
apt update
apt upgrade
apt install cmake
apt install libssl-dev
apt install libboost-all-dev
apt install libncurses5-dev libncursesw5-dev
8. 필요 패키지 설치 후 다시 make 진행
설치 완료
9. mysql 그룹 및 사용자 추가
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
10. mysql 폴더 권한 및 소유자 변경
chown -R mysql:mysql /data/app/mysql
11. mysql bin 폴더 이동
cd /data/app/mysql/bin
12. data 폴더 초기화 및 root 초기 비밀번호 확인
다른 블로그 가이드를 보면 아래와 같이 data폴더를 초기화할 때 basedir, datadir을 입력하게 되어있지만 입력하면 아래와 같은 오류가 발생했다.
./mysqld --initialize --user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
### 오류 발생 ###
Too many arguments (first extra is ' --basedir=/data/app/mysql').
The newly created data directory /data/app/mysql/data/ by --initialize is unusable. You can remove it.
Aborting
이미 cmake 과정에서 basedir과 datadir을 지정했기 때문에 없어도 될 거라고 판단하여 해당 옵션은 빼고 진행하였더니 정상적으로 data 폴더가 초기화되었습니다.
./mysqld --initialize --user=mysql
### 초기화 결과 ###
[Server] /data/app/mysql/bin/mysqld (mysqld 8.0.26) initializing of server in progress as process 46324
[Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
[Server] --collation-server: 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
[InnoDB] InnoDB initialization has started.
[InnoDB] InnoDB initialization has ended.
[Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
[Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
[Server] A temporary password is generated for root@localhost: s+3RNny7*/%G
위와 같이 ROOT 비밀번호 확인
13. Mysql 실행 및 프로세스 확인
./mysqld_safe --user=mysql &
ps -ef | grep mysql
14. ROOT 비밀번호 초기화
ALTER USER 'root'@'localhost' IDENTIFIED BY '13Reqf#51@';
저처럼 삽질하지 않고 설치하시는데 도움이 되길 바랍니다!
'OS > Linux' 카테고리의 다른 글
[Linux, Ubuntu] Apache 수동 설치 (2.4.59) tar 최신 다운로드 링크 포함 (0) | 2024.05.29 |
---|---|
[Linux, CentOS] 서버 부팅 후 아파치 톰캣 자동 실행 (0) | 2024.02.02 |