1. 유저생성
# groupadd mysql
# useradd -M -g mysql mysql
# cat /etc/passwd
2. MySQL 컴파일을 위해 필수 라이브러리 설치 (의존성 설치)
# yum -y install ncurses-devel
# yum -y install perl
# yum -y install perl-Data-Dumper
# yum -y install cmake
# yum -y install wget
# yum -y install gcc-c++
# yum -y install openssl
# yum -y install openssl-devel
3. MySQL 설치 (5버전)_
# wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15.tar.gz
# tar xvfz mysql-5.6.15.tar.gz
# cd mysql-5.6.15
cmake \
-DCMAKE_INSTALL_PREFIX=/mydata/dev/mysql \
-DMYSQL_UNIX_ADDR=/mydata/dev/mysql/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DMYSQL_DATADIR=/mydata/dev/mysql/data \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=18306 \
-DENABLE_DOWNLOADS=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=../boost_1_59_0
# make
# make install
4. 디렉토리 소유자 변경
# mkdir /mydata/dev/mysql/tmp
# chown -R mysql:mysql /mydata/dev/mysql
# chown mysql:root /mydata/dev/mysql/tmp
5. MySQL 환경 설정
# vi /etc/my.cnf
[client]
port = 18306
socket = /mydata/dev/mysql/tmp/mysql.sock
character-set = utf8
[mysqld]
port = 18306
socket = /mydata/dev/mysql/tmp/mysql.sock
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
character-set-server=utf8
collation-server=utf8_general_ci
init_connect=SET collation_connection=utf8_general_ci
init_connect=SET NAMES utf8
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
default-character-set = utf8
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
6. 기본 데이터 베이스 설정
6.1 경로 이동
cd /mydata/dev/mysql
6.2 설치
/mydata/dev/mysql/bin/mysql_install_db
--user=mysql
--datadir=/mydata/dev/mysql/data
7. 환경 변수 설정
# vi /etc/profile
#mysql
export PATH=$PATH:/mydata/dev/mysql/bin
# source /etc/profile
8. mysql 실행
# mysql
9. mysql 서비스 등록
# vi /usr/lib/systemd/system/mysql.service
[Unit]
Description=MySQL Community Server
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=mysql.service
[Service]
User=mysql
Group=mysql
# Execute pre and post scripts as root
PermissionsStartOnly=true
# Needed to create system tables etc.
#ExecStartPre=
# Start main service
ExecStart=/mydata/dev/mysql/bin/mysqld_safe
# Don't signal startup success before a ping works
#ExecStartPost=
# Give up if ping don't get an answer
TimeoutSec=300
Restart=always
PrivateTmp=false
# systemctl enable mysql.service
# systemctl start mysql.service
10. MySQL 데몬 실행
# /mydata/dev/mysql/bin/mysqld_safe &
ps -ef | grep mysql
11. 방화벽 설정
MySQL
firewall-cmd --permanent --zone=public --add-port=18306/tcp
firewall-cmd --reload
12. 임시비밀번호 발급
MySQL 5.7 설치 하면 root 비밀번호를 임시비밀번호로 발급 해준다.
# vi /root/.mysql_secret
입력하면 하단의 내용처럼 비밀번호를 보여준다.
# Password set for user 'root@localhost' at 2021-01-07 11:50:50
):,uJKxr8jpn
이후 mysql 에 접솔 한뒤 비밀 번호 초기화 및 변경 해준다.
비밀번호변경가이드