본문으로 건너뛰기

mysql 5.5.x 설치 방법은 무엇인가요?

💡 요약 정리

  • mysql 5.5 이상은 cmake를 통해 컴파일 방식으로 설치해야 합니다.
  • CentOS 최신 버전은 rpm 설치 가능하지만, 구버전은 소스 설치 필요합니다.
  • 설치 순서는 cmake 설치 → mysql 사용자 추가 → mysql 컴파일 및 설치 → 설정 파일 구성 → 데몬 등록 및 실행입니다.

mysql 5.5 이상 버전의 경우는 cmake를 이용해서 컴파일 하게 됩니다.


1. cmake 설치

[root@localhost src]# yum install cmake
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp://ftp.daum.net
 * extras: ftp://ftp.daum.net
 * updates: ftp://ftp.daum.net
Excluding Packages in global exclude list
Finished
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package cmake.x86_64 0:2.6.4-5.el5.4 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved
==============================================================================================================================================
 Package                           Arch                            Version                                              Repository        Size
==============================================================================================================================================
Installing:
 cmake                             x86_64                          2.6.4-5.el5.4                                        base              6.5 M

Transaction Summary
==============================================================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 6.5 M
Is this ok [y/N]: y
Downloading Packages:
cmake-2.6.4-5.el5.4.x86_64.rpm                                                      | 6.5 MB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : cmake                                                                             1/1

Installed:
  cmake.x86_64 0:2.6.4-5.el5.4

Complete!
[root@localhost src]#

최신 버전의 CentOS 배포판에는 rpm 버전의 cmake 패키지가 제공되지만, rpm이 제공되지 않는 이전 버전의 CentOS의 경우는 src로 컴파일해서 cmake를 설치해야 합니다.

  • cmake src 설치 http://www.cmake.org 파일 다운로드, 압축 해제 후 아래 순서로 cmake를 설치합니다. 설치되는 경로는 /usr/local/share/cmake-xx입니다.
[root@localhost src]# ./bootstrap && make && make install

2. mysql 사용자 추가

[root@localhost src]# useradd mysql

3. source 파일 압축 해제 및 설치

[root@localhost src]# tar xvzfp mysql-5.5.28.tar.gz
[root@localhost src]# cd mysql-5.5.28
[root@localhost mysql-5.5.28]# ls
BUILD               INSTALL-SOURCE         cmake              extra          man         regex        storage        vio
BUILD-CMAKE         INSTALL-WIN-SOURCE     cmd-line-utils     include        mysql-test   scripts      strings        win
CMakeLists.txt      README                 config.h.cmake     libmysql       mysys        sql          support-files  zlib
COPYING             VERSION                configure.cmake    libmysqld      packaging    sql-bench    tests
Docs                client                 dbug               libservices    plugin       sql-common   unittest
[root@localhost mysql-5.5.28]# cmake -DCMAKE_INSTALL_PREFIX=/home/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 \\
-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=1 \\
-DWITH_EXTRA_CHARSETS=all -DWITH_SSL=yes -DWITH_ZLIB=system
-- Looking for strvis
-- Looking for strvis - not found
-- Looking for strunvis
-- Looking for strunvis - not found
-- Looking for include files HAVE_LIBAIO_H
-- Looking for include files HAVE_LIBAIO_H - not found.
-- Looking for io_queue_init in aio
-- Looking for io_queue_init in aio - not found
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS - Success
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC - Success
-- Check size of pthread_t
-- Check size of pthread_t - done
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/src/mysql-5.5.28
[root@localhost mysql-5.5.28]#
[root@localhost mysql-5.5.28]# make

(생략)

[root@localhost mysql-5.5.28]# make install

(생략)


4. my.cnf 파일 생성

[root@localhost mysql]# cd /home/mysql/
[root@localhost mysql]# ls
COPYING  INSTALL-BINARY  README  bin  data  docs  include  lib  man  mysql-test  scripts  share  sql-bench  support-files
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ls
binary-configure         config.medium.ini        magic                  my-innodb-heavy-4G.cnf
my-medium.cnf            mysql-log-rotate         mysqld_multi.server   config.huge.ini
config.small.ini         my-huge.cnf              my-large.cnf          my-small.cnf
mysql.server             ndb-config-2-node.ini
[root@localhost support-files]# cp my-innodb-heavy-4G.cnf /etc/my.cnf

5. mysql 실행 데몬 활성화

[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# chkconfig mysqld on
[root@localhost support-files]# chkconfig --list | grep mysql
mysqld             0:off   1:off   2:on   3:on   4:on   5:on   6:off

6. mysql DB 생성

[root@localhost mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!
[root@localhost mysql]#

7. mysql 데몬 실행 및 접속

[root@localhost support-files]# /etc/init.d/mysqld start
Starting MySQL.                                                                 [  OK  ]
[root@localhost support-files]# /etc/init.d/mysqld restart
Shutting down MySQL.                                                            [  OK  ]
Starting MySQL.                                                                 [  OK  ]
[root@localhost support-files]#
[root@localhost support-files]# /home/mysql/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.28-log Source distribution

Copyright (c) 2000, 2012, 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>