웹마스터 팁

Linux 에서 Mysql 설치법

2003.10.31 16:11

화니

Linux 초보들을 위한 글입니다.

제가 너무 허접 삽질을 많이 해서 익힌거라 ㅠㅠ

고수분들에게는 너무나 쉬운 것이겠지만

http://database.sarang.net 이나
http://www.linux.co.kr 쪽에 가니
많은 분들이 저랑 같은 삽질을 하더군요

오픈되어 있는 리눅스 메뉴얼대로 하니까 안되는 부분이 많더라구요 ㅠㅠ

쪽팔리지만 글 한번 올려 봅니다.

mysql.com 에 가서 최신 버젼을 다운 받으세요.
단, 소스를 다운 받지 마시고 컴파일이 다 되어진 파일( xxxx-linux-i686.tar.gz) 을 받습니다.


2003년 10월 31일

mysql-standard-4.0.18-pc-linux-i686.tar.gz  

이 파일을 받아 왔습니다.

더 상위 버젼을 받으셔도 됩니다.

참고로 소스파일의 파일명은 mysql-버젼.tar.gz 입니다.

소스를 받아 오신 분들은 아래 방법으로는 설치가 안됩니다.



[root@linux root]# tar zxvf mysql-standard-4.0.18-pc-linux-i686.tar.gz

압축을 풉니다


압축이 풀려서 생긴 디렉토리를  /usr/local/mysql 로 이동 시킵니다.
( 꼭 거기에 하실 필요는 없고 .. 원하는 디렉토리로 해도 됩니다 )

[root@linux root]mv mysql-standard-4.0.18-pc-linux-i686 /usr/local/mysql
[root@linux root]# cd /usr/local/mysql


설치 스크립트를 실행 합니다.

[root@linux root]#./scripts/mysql_install_db
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
031022 22:37:09  ./bin/mysqld: Shutdown Complete

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:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h myserver.co.kr password 'new-password'
See the manual for more instructions.

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

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com

[root@linux root]#

위와 같은 메시지가 나오면 90% 끝입니다.

자 이제 mysql 작동을 위해 기본 설정을 해 줘야 합니다.
아래 부분에서 가장 해메는 부분 입니다.


[root@linux root]# groupadd mysql    
이미 있는 그룹이라고 나오면 그냥 넘어 가세요
[root@linux root]# adduser -g mysql mysql
이미 있는 유저라고 나오면 그냥 넘어 가세요
[root@linux root]# chown root.mysql /usr/local/mysql -R
root 로 권한을 줍니다.
[root@linux root]# chown mysql /usr/local/mysql/data -R
data 의 권한을 mysql 로 변경 합니다.
[root@linux root]# cp support-files/my-medium.cnf /etc/my.cnf
환경 설정 파일을 복사 합니다.

/etc/my.cnf 파일을 열어
한글 검색이 가능하도록 아래의 설정을 추가합니다.

[root@linux root]# vi /etc/my.cnf

default-character-set= euc_kr



자 이제 데몬을 띄웁니다.


[root@linux root]# ./bin/safe_mysqld --user=mysql &
[1] 5217
[root@linux root]# Starting mysqld daemon with databases from /usr/local/mysql/data


데몬이 정상적으로 떠 있는지 확인 해 봅니다.

[root@linux root]# ps ax|grep mysql
1634 pts/0    S      0:00 /bin/sh ./bin/safe_mysqld --user=mysql
1660 pts/0    S      0:00 [mysqld]
1662 pts/0    S      0:00 [mysqld]
1663 pts/0    S      0:00 [mysqld].
.
.


만약 데몬이 정상적으로 뜨지 않고
shutdown 어쩌구 메시지가 나오면
권한 변경 부분에서  잘못 된 경우가 많습니다.
그 부분을  다시 설정 해 보세요

그리고 서버가 부팅 될때 자동적으로 Mysql 돌아가게 설정 합니다.


[root@linux root]vi/etc/rc.d/rc.local  

/usr/local/mysql/bin/safe_mysqld --user=mysql &

위 내용을 추가 하면 됩니다.