728x90
CentOS 7에서 MySQL 5.7를 바이너리 아카이브 파일로 설치하는 방법
테스트 환경
- 운영체제 버전 정보
$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
$ getconf LONG_BIT
64
- DB : mysql 5.7.15
MySQL 계정 생성
groupadd -g 27 mysql
useradd -m -c "MySQL Server" -d /usr/local/mysql -s /bin/false -g 27 -u 27 mysql
- MySQL Community Server 다운로드 받기
작업 디렉토리로 이동
cd /usr/local/src
아카이브 파일 다운로드
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz
아카이브 파일 해제
tar xfz mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz
MySQL 5.7(mysql-5.7.15-linux-glibc2.5-x86_64) 디렉토리 이동 및 이름 변경
mv mysql-5.7.15-linux-glibc2.5-x86_64 /usr/local/mysql
MySQL 데이터 디렉토리 생성
mkdir -p {etc,data,tmp,logs}
chmod 750 logs
touch logs/mysqld.log
MySQL 구성(my.cnf) 파일 위치 확인
mysqld --verbose --help | grep -A 1 'Default options'
$ /usr/local/mysql/bin/mysqld --verbose --help | grep -A 1 'Default options'
mysqld: Can't change dir to '/usr/local/mysql/data/' (Errcode: 2 - No such file or directory)
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
MySQL 구성(my.conf) 파일 복사(my-default.cnf 복사)
cp support-files/my-default.cnf /usr/local/mysql/etc/my.cnf
MySQL 구성(my.cnf) 파일에 설정 추가
cat <<EOF >> /usr/local/mysql/etc/my.cnf
###ADD
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
server_id=1
socket=/usr/local/mysql/tmp/mysql.sock
symbolic-links=0
[mysqld_safe]
log-error=/usr/local/mysql/logs/mysqld.log
pid-file=/usr/local/mysql/tmp/mysql.pid
EOF
MySQL 디렉토리 소유자(mysql) 변경
chown -R mysql.mysql /usr/local/mysql
728x90
MySQL 초기화(initialize)
bin/mysqld --defaults-file=/usr/local/mysql/etc/my.cnf --initialize --user=mysql
---output---
2022-03-03T13:14:27.349870Z 1 [Note] A temporary password is generated for root@localhost: KiseA4kx#!aW
bin/mysql_ssl_rsa_setup --defaults-file=/usr/local/mysql/etc/my.cnf
MySQL 서비스 시작(mysqld_safe)
bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf --user=mysql &
---output---
2022-03-03T13:17:53.168123Z mysqld_safe Logging to '/usr/local/mysql/logs/mysqld.log'.
2022-03-03T13:17:53.255147Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
MySQL 서비스 확인
ps -ef | grep -v grep | grep mysql
$ ps -ef | grep -v grep | grep mysql
root 10996 9902 0 22:17 pts/0 00:00:00 /bin/sh bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf --user=mysql
mysql 11193 10996 0 22:17 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/logs/mysqld.log --pid-file=/usr/local/mysql/tmp/mysql.pid --socket=/usr/local/mysql/tmp/mysql.sock --port=3306
MySQL 접속(root 계정으로 접속)
bin/mysql --socket=/usr/local/mysql/tmp/mysql.sock -uroot -p'KiseA4kx#!aW'
$ bin/mysql --socket=/usr/local/mysql/tmp/mysql.sock -uroot -p'KiseA4kx#!aW'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.15
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
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>
ALTER USER 문을 사용하여 암호를 재설정
alter user 'root'@'localhost' identified by 'netpassword';
mysql> alter user 'root'@'localhost' identified by 'netpassword';
Query OK, 0 rows affected (0.00 sec)
MySQL 서비스 중지
bin/mysqladmin -h127.0.0.1 -uroot -p shutdown
$ bin/mysqladmin -h127.0.0.1 -uroot -p shutdown
Enter password:
---output---
2022-03-03T13:57:29.210843Z 0 [Note] Shutting down plugin 'sha256_password'
2022-03-03T13:57:29.211060Z 0 [Note] Shutting down plugin 'mysql_native_password'
2022-03-03T13:57:29.211245Z 0 [Note] Shutting down plugin 'binlog'
2022-03-03T13:57:29.211748Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
2022-03-03T13:57:29.315738Z mysqld_safe mysqld from pid file /usr/local/mysql/tmp/mysql.pid ended
728x90
'리눅스' 카테고리의 다른 글
[리눅스] Cockpit 관리 도구 설치(WEB UI 기반) (0) | 2022.03.05 |
---|---|
configure, make, make install 명령어 (0) | 2022.03.04 |
CentOS 7에 MySQL 5.7을 바이너리 설치하는 방법(binary) (0) | 2022.03.03 |
리눅스에서 my.cnf 파일을 찾는 방법 (0) | 2022.03.03 |
[리눅스] 압축 명령어 tar, gzip (0) | 2022.03.03 |