제 1강 MySQL 설치하기

  출처 : http://gwangcom.co.kr

 
 제 1강  MySQL 설치하기

MySQL은 DB중 강력한 기능을 발휘한다.
특히
LINUX 서버 에서 Apach와 PHP와 연동해서 정말로 막강한 기능을 발휘한다.
물 론 Oracle보다는 기능상에선 제약이 좀 있기는 하지만 중소규모의 사이트에서
딱 제격이다고 할수 있다.
작지만 빠르고 강력한 기능을 원하다면 MySQL 를 사용하기를 강력히 권장한다.

MySQL에서 한글 캐릭터 셋으로 정렬을 하기 위해 서는 소스 컴파일을 해야 한다.
Apache,PHP를 함께 연동하려면 좀 더 복잡한 과정을 거쳐야만 한다.
여기서는 일단 Apache,PHP 는 제외하고 생각한다.
(추후에 기회가 된다면 APM연동에 대해서 강좌 를 올리겠다.
설치하는 데는 레드햇 계열의 6.0  이상의 LINUX 라면 전혀 문제가 없 다.

(1) 설치 전에 준비할 사항

 MySQL 최신 버전의 소스가 필요하 다.
소스는 아래 주소에서 다운로드받을수 있다.

  http://www.mysql.org">http://www.mysql.org

이 글을 쓰고 있는 현재 최신 버전은 3.22.32 버전이다.
/root/sw(임의의 어떤 디렉토리도 가능하다) 에 소스배포판이 있다고 가정한다

1.압축을 푼다

# cd   /root/sw

# tar -xvzf   mysql-3.22.32.tar.gz

#  tar -xvzf mysql-3.22.32.tar.gz

mysql- 3.22.32/
mysql-3.22.32/Makefile.in
mysql- 3.22.32/README
mysql-3.22.32/stamp-h.in
mysql- 3.22.32/Makefile.am

...
...
...

mysql- 3.22.32/support-files/mysql.spec.sh
mysql-3.22.32/support- files/my-example.cnf.sh
mysql-3.22.32/support-files/mysql-log- rotate.sh
mysql-3.22.32/support-files/mysql.server.sh
mysql- 3.22.32/support-files/binary-configure.sh

그러면 mysql-3.22.32라는 디렉토리가 생 성된다.

2.압축이 풀린 디렉토리로 이 동한다.

# cd mysql-3.22.32

3.configure 스크립트 실행

# ./configure  -- prefix=/usr/local/mysql  -- localstatedir=/usr/local/mysql/data  --with-charset=euc_kr

cofigure 를 실행한다.
사용가능한 옵션을 자세히 보려면 --help 를 붙여주면 된다.

# ./configure --help

Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
  --cache- file=FILE       cache test results in FILE
  -- help            ;       print this message
  --no- create          &nb sp;  do not create output files
  --quiet, -- silent       do not print `checking...' messages
  -- version          &n bsp;    print the version of autoconf that created configure
...
 

-- prefix : 컴파일이 끝난 후 파일들이 인스톨되는 디렉토리를 정해준 다.
--with- charset  : 정렬에 사용될 캐릭터 셋을 정해 준다. 한글정렬을 위해 필요하 다.
--localstatedir  : 데이타베이스가 저장될 위치를 지정해준다.

4.컴파일하기

이젠 컴파일할 준비가 다 끝났다.
컴 퓨터사양에 따라 다르지만 make 하는데 펜티엄 셀러론 466Mhz 에서 약 8분 정도 걸렸 다.

# make

# make

make  all-recursive
make[1]: Entering directory `/tmp/mysql- 3.22.32'
Making all in Docs
make[2]: Entering directory `/tmp/mysql- 3.22.32/Docs'
make[2]: Nothing to be done for `all'.
...
...
...
 

5.인스톨하기

컴파일에 의해 만들어진 파일들을 인스톨하 자

# make install

# make install      

Making install in Docs
make[1]: Entering directory `/tmp/mysql-3.22.32/Docs'
make[2]: Entering directory `/tmp/mysql-3.22.32/Docs'
make[2]: Nothing to be done for `install-exec- am'.
/bin/sh ../mkinstalldirs /usr/local/mysql/info
mkdir /usr/local/mysql
...
...
...
make[2]: Leaving directory `/tmp/mysql-3.22.32'
make[1]: Leaving directory `/tmp/mysql-3.22.32'

#


6. 권한 테이 블 초기화 :  mysql_install_db 실행

 위에서 인스톨된 MySQL 디렉토리로 이동한다.

# cd /usr/local/mysql 

MySQL 데이터베이스의 권한을 관리하는 ySQL에 테이블을 생성하는 스크립트를 실행 한다. 

# ./bin/mysql_install_db 

 

# ./bin/mysql_install_db

Creating db table
Creating host table
Creating user table
Creating func table
Creating tables_priv table
Creating columns_priv table

 

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 !
This is done with:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
See the manual for more instructions.

 

Please report any problems with the /usr/local/mysql/bin/mysqlbug script!

...

[root@localhost mysql] #

 

자 그럼 한번 MySQL를 실행 해보자

# /usr/local/mysql/bin/safe_mysql &


Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your ySQL connection id is 5 to server version: 3.22.32

Type 'help' for help.

mysql>
 

위와 같은 내용이 나왔다면 설치에 성공 한 것이다.

축하드립니다.


이상으로 MySQL의 컴파일 작업은 모두 끝났다.
물론 다른 방법도 있다.
다음 강좌에서 MySQL에  대해 자세히 다룰 것이다.