OS

2022.02.14 15:39

mysql 5.7.31 compile 설치

  • 비아웹 오래 전 2022.02.14 15:39 인기
  • 10,463
    0

1. 설치 환경

OS : CentOS Linux release 7.6.1810 (Core)

SELINUX : disabled

테스트 일자 : 2020.11.13

2. 의존성 패키지 설치

: mysql 5.7 컴파일시 cmake 가 사용되며, ncurses 와 openssl 라이버러리 필수

[root@viaweb source]# yum install wget cmake ncurses ncurses-devel openssl-devel

3. 소스 다운로드

https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.31.tar.gz https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download


[root@viaweb source]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.31.tar.gz
[root@viaweb source]#
wget -O boost_1_59_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download

4. 컴파일 진행

a. 다운로드 받은 파일 압축 해제

[root@viaweb source]# tar -zxvpf boost_1_59_0.tar.gz
[root@viaweb source]# tar -zxvpf mysql-boost-5.7.31.tar.gz

b. 컴파일 옵션

[root@viaweb source]# cd mysql-5.7.31
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DDOWNLOAD_BOOST=1-DWITH_BOOST=../boost_1_59_0 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all

c. 컴파일 옵션 설명

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ ## 설치 경로
-DMYSQL_DATADIR=/usr/local/mysql/data \ ## mysql data 경로
-DSYSCONFDIR=/etc \ ## my.cnf 위치
-DDOWNLOAD_BOOST=1-DWITH_BOOST=../boost_1_59_0 \ ## 의존성 패키지 boost 경로
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ ## DB engine
-DWITH_PARTITION_STORAGE_ENGINE=1 \ ## DB engine
-DWITH_FEDERATED_STORAGE_ENGINE=1 \ ## DB engine
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ ## DB engine
-DWITH_MYISAM_STORAGE_ENGINE=1 \ ## DB engine
-DENABLED_LOCAL_INFILE=1 \ ## local_infile 변수 사용
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ ## mysql.socket 경로
-DDEFAULT_CHARSET=utf8 \ ## default character set
-DDEFAULT_COLLATION=utf8_general_ci \ ## default 콜레이션 지정
-DWITH_EXTRA_CHARSETS=all \ ## 추가 지원 케릭셋
-DWITH_SSL=/usr/local/openssl ## 시스템 설치 openssl 이 아닌 특정 버전 사용시

d. make

make 화면 : 오래 걸립니다.

e. make install

5. 사용자 추가

[root@viaweb source]# groupadd -g 27-o -r mysql
[root@viaweb source]# useradd -M-g mysql -o -r -d /usr/local/mysql/data -s /bin/false -u 27 mysql

6. mysql data 폴더 생성 및 소유권 부여

[root@viaweb mysql]# mkdir /usr/local/mysql/data
[root@viaweb mysql]# chown mysql:mysql data

7. mysql path 주기

[root@viaweb mysql]# echo "export PATH=/usr/local/mysql/bin:$PATH">>/etc/profile
[root@viaweb mysql]# source /etc/profile
[root@viaweb mysql]# which mysql /usr/local/mysql/bin/mysql

8. /etc/my.cnf

[client]
default-character-set = utf8
port =3306 socket =/tmp/mysql.sock
default-character-set = utf8
 
[mysqld]
socket=/tmp/mysql.sock
datadir=/usr/local/mysql/data
basedir =/usr/local/mysql
#user = mysql
#bind-address =0.0.0.0
skip-external-locking
key_buffer_size =384M
max_allowed_packet =1M
table_open_cache =512
sort_buffer_size =2M
read_buffer_size =2M
read_rnd_buffer_size =8M
myisam_sort_buffer_size =64M
thread_cache_size =8
query_cache_size =32M
 
## dns query
skip-name-resolve
## connection
max_connections =1000
max_connect_errors =1000
wait_timeout=60
 
## slow-queries
#slow_query_log =/var/log/slow-queries.log
#long_query_time =3
#log-slow-queries =/var/log/mysql-slow-queries.log
 
## timestamp
explicit_defaults_for_timestamp
symbolic-links=0
 
## binlog
server-id =1
log-bin =/usr/local/mysql/data/mysql-bin
binlog_cache_size =2M
max_binlog_size =100M
expire_logs_days =7
 
## log
log_warnings =2
log_error_verbosity =3
log-error =/usr/local/mysql/data/mysqld.log
pid-file =/usr/local/mysql/data/mysqld.pid
 
## chracter
character-set-client-handshake=FALSE
init_connect =SET
collation_connection = utf8_general_ci
init_connect =SETNAMES utf8
character-set-server = utf8
collation-server = utf8_general_ci
symbolic-links=0
 
## Password Policy
plugin-load-add=validate_password.so
validate_password_policy=0## LOW
#validate_password_policy=1 ## MEDIUM
#validate_password_policy=2 ## STRONG
 
## MyISAM Spectific options
default-storage-engine = myisam
key_buffer_size =32M
bulk_insert_buffer_size =64M
myisam_sort_buffer_size =128M
myisam_max_sort_file_size =10G
myisam_repair_threads =1
 
## INNODB Spectific options
default-storage-engine = InnoDB
#skip-innodb
#innodb_additional_mem_pool_size =16M
#innodb_buffer_pool_size =1024MB
innodb_data_file_path = ibdata1:10M:autoextend
#innodb_write_io_threads =8
#innodb_read_io_threads =8
#innodb_thread_concurrency =16
#innodb_flush_log_at_trx_commit =1
#innodb_log_buffer_size =8M
#innodb_log_file_size =128M
#innodb_log_files_in_group =3
#innodb_max_dirty_pages_pct =90
#innodb_lock_wait_timeout =120
 
[mysqldump]
default-character-set = utf8
max_allowed_packet =16M
 
[mysql]
no-auto-rehash
default-character-set = utf8
 
[myisamchk]
key_buffer_size =256M
sort_buffer_size =256M
read_buffer =2M
write_buffer =2M

9. mysql 서비스 등록

[root@viaweb mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@viaweb mysql]# chkconfig --level 345 mysql on

10. mysql DB initialize

[root@viaweb mysql]# /usr/local/mysql/bin/mysqld --initialize --user=mysql
[root@viaweb mysql]# chown -R mysql:mysql /usr/local/mysql/data

10. mysql start

[root@viaweb mysql]# service mysql start

11. mysql 초기 패스워드

: DB 초기화시 초기 패스워드가 자동 설정되며, 해당 패스워드는 반드시 변경해야만 사용 가능 합니다.

[root@viaweb log]# grep root /usr/local/mysql/data/mysqld.log
2020-11-13T02:42:13.239194Z 1[Note]A temporary password is generated for root@localhost: kkssb&QtU8jG

초기 패스워드

12. mysql 접속 및 패스워드 설정

[root@viaweb log]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 2
Server version:5.7.31-log
 
Copyright(c)2000,2020, 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 'root'@'localhost' identified by 'viaweb.co.kr';
Query OK,0 rows affected(0.01 sec)
 
mysql> flush privileges;
Query OK,0 rows affected(0.00 sec)

cf. 서비스 설정 후 firewalld 나 iptables 허용 해주셔야 원격 서비스 가능합니다.

 

감사합니다.

해당 내용이 검색하는 시간을 줄여드렸길 바랍니다.

서버호스팅 비아웹

  • 공유링크 복사

    댓글목록

    등록된 댓글이 없습니다.