# 설치 준비
패키지 설치 - 안해도 되지만 중간중간 라이브러리를 못 찾는 등 자잘한 오류 발생 가능
yum -y install make gcc gcc-c++ autoconf \
automake libtool pkgconfig findutils \
zlib-devel openldap-devel openssl-devel \
libxml2-devel freetype-devel libtool-ltdl-devel \
expat-devel libssh2 libcurl libssl libssh curl-devel \
libssh2-devel bzip2-devel libjpeg-devel gmp-devel \
libmcrypt-devel mysql-devel mysql-lib ncurses-devel
공유라이브러리 설정
echo -e 'export CFLAGS="-fPIC" \nexport CC="gcc"' >> /etc/profile && source /etc/profile
cmake 설치 (원하는 버전)
wget https://cmake.org/files/v2.8/cmake-2.8.4.tar.gz
tar xf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./bootstrap
make && make install
/usr/local/bin/cmake --version
# 설치
설치 파일 다운로드
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.5.10.tar.gz
tar xf mysql-5.5.10.tar.gz
cd mysql-5.5.10
설치
MYSQLHOME=/usr/local/mysql
MYSQLDATA=/home/virtual/mysql/data
echo $MYSQLHOME # mysql 홈 디렉토리 확인
echo $MYSQLDATA # mysql 데이터 디렉토리 확인
cmake -DCMAKE_INSTALL_PREFIX=$MYSQLHOME \
-DMYSQL_DATADIR=$MYSQLDATA \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DSYSCONFDIR=/etc \
-DDEFAULT_CHARSET=euckr \
-DDEFAULT_COLLATION=euckr_korean_ci \
-DMYSQL_TCP_PORT=3306 \
-DWITH_EXTRA_CHARSETS=all
# 설정
유저 생성
groupadd -g 400 mysql
useradd -u 400 -g 400 -d $MYSQLHOME -s /bin/false mysql
mkdir -p $MYSQLDATA
서비스 등록
cp support-files/mysql.server /etc/init.d/mysqld
sed -i "s|basedir=|basedir=$MYSQLHOME|g" /etc/init.d/mysqld
sed -i "s|datadir=|basedir=$MYSQLDATA|g" /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
chown root.root /etc/init.d/mysqld
chkconfig mysqld on
vi /etc/init.d/mysqld # 확인
basedir=/usr/local/mysql
datadir=/home/virtual/mysql/data
my.conf 설정
vi /etc/my.cnf
[mysqld]
datadir=/home/virtual/mysql/data
basedir=/usr/local/mysql
port=3306
socket=/tmp/mysql.sock
log-bin=mysql-bin
pid-file=/home/virtual/mysql/data/mu.pid
#pid-file=/var/run/mysql/mu.pid
slow-query-log = 1
long_query_time = 1
slow_query_log_file = /home/virtual/mysql/data/slow_query.log
#general_log = 1
#general_log_file = /home/virtual/mysql/data/general_query.log
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
back_log = 100
max_connections = 1000
max_connect_errors = 100
table_open_cache = 2048
max_allowed_packet = 1000M
join_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
bulk_insert_buffer_size = 16M
thread_cache_size = 128
thread_concurrency = 16
thread_stack = 192K
max_heap_table_size = 128M
tmp_table_size = 128M
[mysqld_safe]
log-error=/home/virtual/mysql/data/mu.log
open_files_limit = 8192
[mysqldump]
quick
max_allowed_packet = 1000M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
###chracter
#character-set-client-handshake=FALSE
init_connect = SET collation_connection = euckr_korean_ci
init_connect = SET NAMES euckr
character-set-server = euckr
collation-server = euckr_korean_ci
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
mysql 라이브러리 세팅 - php에서 사용 예정
$MYSQLHOME/scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql --basedir=$MYSQLHOME --datadir=$MYSQLDATA
mysql 디렉토리 권한 설정
chmod 711 $MYSQLHOME
chmod 700 $MYSQLDATA
chmod 751 $MYSQLHOME/bin
chmod 750 $MYSQLHOME/bin/*
chmod 755 $MYSQLHOME/bin/mysql
chmod 755 $MYSQLHOME/bin/mysqldump
mysql 패스워드 설정
mysqladmin -u root password 'passwd'
실행
systemctl status mysql # 상태 확인
systemctl start mysql # 시작
systemctl stop mysql # 중지
'System > CentOS | Ubuntu' 카테고리의 다른 글
[Linux] CPU 100% agetty --noclear tty1 linux 조치 (0) | 2023.01.16 |
---|---|
[Linux] ssh 접속 불가 mm_request_receive_expect (0) | 2023.01.16 |
[Ubuntu 16.04] Bash가 이상해요 (0) | 2021.05.06 |
[CentOS] 6 -> 7 업그레이드 (0) | 2021.04.13 |
[CentOS] LVM xfs - 확장, 축소 (0) | 2021.04.13 |