본문 바로가기

개발 관련 지식/MySQL

[MySQL] MySQL 버전 5.5 이상 소스 설치(리눅스)

* MySQL 버전 5.5 이상 소스 설치(리눅스)


OS: Linux [장비명] 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

기존 MySQL : Server version: 5.0.95-log Source distribution


다른 MySQL 의 DB를 내가 사용하는 장비로 옮겨와야 하는 상황..

하지만 MySQL 버전이 달라 mysqldump 로 옮겨지지 않는 상황이 발생하였다.

위와 같이 이미 MySQL 이 설치되어 있는 상황..

추가로 MySQL 을 설치하기 위해서는 소스로 설치해보기로 결정..

설치할 MySQL : Server version: 5.6.15-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)


1. 소스 다운로드

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15.tar.gz


2. 압축 해제(gzip, tar 압축 풀기)

tar zxvf mysql-5.6.15.tar.gz

=> 해제된 디렉토리명을 mysql-3307 로 변경하였음(기존 mysql 에는 영향을 주지 않기 위해 소스로 설치)


3. configure 대신 cmake 를 이용

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-3307 -DMYSQL_DATADIR=/usr/local/mysql-3307/data -DDEFAULT_CHARSET=euckr -DWITH_EXTRA_CHARSETS=all -DMYSQL_UNIX_ADDR=/tmp/mysql-3307.sock -DSYSConFDIR=/usr/local/mysql-3307/etc/my.cnf -DMYSQL_TCP_PORT=3307


4. 컴파일 & 설치

make && make install


5. 디렉토리 생성 및 권한 부여

cd /usr/local/mysql-3307

mkdir etc

mkdir data


cd /usr/local

chown -R mysql:mysql mysql-3307


6. cnf 파일 생성 및 설정

cp /usr/local/mysql-3307/support-files/my-default.cnf /usr/local/mysql-3307/etc/my.cnf

vi my.cnf

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

# *** default location during install, and will be replaced if you

# *** upgrade to a newer version of MySQL.


[client]

port            = 3307

socket          = /usr/local/mysql-3307/mysql.sock

default-character-set = euckr


[mysqld]

port            = 3307

socket          = /usr/local/mysql-3307/mysql.sock

skip-federated

character-set-server = euckr

collation-server    = euckr_korean_ci

character-set-client-handshake = false


# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M


# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin


# These are commonly set, remove the # and set as required.

# basedir = .....

# datadir = .....

# port = .....

# server_id = .....

# socket = .....


# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M


#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES



[참고] my.cnf 파일 우선순위

: 위의 디렉토리에 my.cnf 파일을 생성하긴 했으나, /etc/my.cnf 파일이 존재하면 우선순위로 읽어들이는 것으로 보여졌다..

 아니면 /etc/my.cnf 파일만을 읽어들인 것일 지도 모른다. 시간 관계상 해당 부분까지는 테스트해보지 못하였다. 

 나중에 해봐야겠군.. 


7. 기본 DB 생성

./scripts/mysql_install_db --user=mysql --defaults-file=/usr/local/mysql-3307/etc/my.cnf --basedir=/usr/local/mysql-3307 --datadir=/usr/local/mysql-3307/data


8. mysqld 실행

cp mysql.server /etc/init.d/mysqld2

(support-files 디렉토리 존재)

service mysqld2 start

Starting MySQL....The server quit without updating PID file (/usr/local/mysql-3307/data/[유저명].pid).[실패]

=> 위와 같이 인터넷에 떠도는 mysql.server 파일을 실행파일로 사용하는 방법은 위와 같이 실패가 떴다.

  아래 로그 파일을 첨부하고, 해당 부분에 대해서는 해결하지 못하고 mysqld_safe 실행파일을 통해 기동하였다.

[error 로그 파일]

160111 21:05:20 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-3307/data

2016-01-11 21:05:21 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and ww

ill be removed in a future release. Please use the full name instead.

2016-01-11 21:05:21 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults__

for_timestamp server option (see documentation for more details).

2016-01-11 21:05:21 10738 [Note] Plugin 'FEDERATED' is disabled.

2016-01-11 21:05:21 10738 [Note] InnoDB: The InnoDB memory heap is disabled

2016-01-11 21:05:21 10738 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2016-01-11 21:05:21 10738 [Note] InnoDB: Compressed tables use zlib 1.2.3

2016-01-11 21:05:21 10738 [Note] InnoDB: Using Linux native AIO

2016-01-11 21:05:21 10738 [Note] InnoDB: Not using CPU crc32 instructions

2016-01-11 21:05:21 10738 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2016-01-11 21:05:21 10738 [Note] InnoDB: Completed initialization of buffer pool

2016-01-11 21:05:21 10738 [Note] InnoDB: Highest supported file format is Barracuda.

2016-01-11 21:05:21 10738 [Note] InnoDB: 128 rollback segment(s) are active.

2016-01-11 21:05:21 10738 [Note] InnoDB: Waiting for purge to start

2016-01-11 21:05:21 10738 [Note] InnoDB: 5.6.15 started; log sequence number 1626133

2016-01-11 21:05:21 10738 [ERROR] /usr/local/mysql-3307/bin/mysqld: unknown variable 'table_cache=512'

2016-01-11 21:05:21 10738 [ERROR] Aborting


2016-01-11 21:05:21 10738 [Note] Binlog end

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'partition'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'BLACKHOLE'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_SYS_TABLES'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_FT_CONFIG'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_FT_DELETED'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_METRICS'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_CMPMEM'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_CMP_RESET'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_CMP'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_LOCKS'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'INNODB_TRX'

2016-01-11 21:05:21 10738 [Note] Shutting down plugin 'InnoDB'

2016-01-11 21:05:21 10738 [Note] InnoDB: FTS optimize thread exiting.

2016-01-11 21:05:21 10738 [Note] InnoDB: Starting shutdown...


./mysqld_safe --user=mysql --defaults-file=/usr/local/mysql-3307/etc/my.cnf --basedir=/usr/local/mysql-3307 --datadir=/usr/local/mysql-3307/data

(scripts 디렉토리 존재)