본문 바로가기

4.개발 및 운영 환경

redhat에서 mysql rpm 설치

설치 순서

  1. mysql용 사용자 추가
  2. rpm 설치
  3. mysql 서비스 등록 및 시작
  4. mysql 패스워드 설정
  5. msyql 접속 테스트

mysql사용자 추가

mysql를 관리할 사용자 추가이다. 실 사용자는 아니고 보안을 위해 추가되는 사용자이다. 실제 접속이 필요 없기에 쉘은 할당하지 않는다.

#useradd -M -s /bin/false -r mysql

-M은 home 디렉토리에 할당하지 않는 것이고, -s 은 쉘을 지정하며, -r은 시스템 계정이라는 의미이다.

rpm설치

redhat 6.2를 설치한다. 기본 basic server로 설치한다 해도 mysql-lib가 설치되어 있는 경우가 있다. 이는 postfix에서 사용하고 있는데 postfix의 mail MTA라서 모두 완벽히 제거가 힘들다. 그래서 강제로 mysql-lib을 제거하고 설치를 진행한다.

#rpm -e mysql-libs --nodeps

설치 제거가 되면, 다음으로 mysql을 설치한다. 최근 mysql은 파일이 6개로 구성되어 있다

  • client
  • devel
  • embedded
  • server
  • shared
  • test

필자는 일반 서버로 개발하기에 embedded을 제외하고 모두 설치하였다. "Uvh" 옵션은 패키지를 업데이트하고 자세한 메시지를 출력한다.

rpm -Uvh MySQL-server-5.5.20-1.linux2.6.x86\_64.rpm
rpm -Uvh MySQL-client-5.5.20-1.linux2.6.x86\_64.rpm
rpm -Uvh MySQL-devel-5.5.20-1.linux2.6.x86\_64.rpm
rpm -Uvh MySQL-shared-5.5.20-1.linux2.6.x86\_64.rpm
rpm -Uvh MySQL-test-5.5.20-1.linux2.6.x86\_64.rpm

mysql 서비스 등록 및 시작

이제 mysql을 시작해보자. 시작하기 전까지는 아무런 동작을 하지 않는다.
redhat에서는 chkconfig와 service을 사용해서 서비스 관리한다.
먼저 mysql을 관리할 스크립트를 init.d에 복사한다.

#cd /etc/init.d
#cp /usr/share/mysql/mysql.server mysqld

이제 서비스에 등록해서 시작한다.

#chkconfig mysqld on
#service mysqld start

mysql의 root사용자 암호 설정

마지막으로 mysql 전체를 관리할 root사용자 암호를 설정한다.
현재 로컬에서 하기 때문에 굳이 호스트를 설정하지 않아도 되낟.

#/usr/bin/mysqladmin -u root password 'new-password'

mysql 접속 테스트

마지막으로 제대로 서비스가 시작되고 root 사용자가 설정되어 있는지 확인해 보자.

#mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \\g.  
Your MySQL connection id is 4  
Server version: 5.5.20 MySQL Community Server (GPL)  

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

여기까지 나왔다면 기본 설치는 끝났다.

참조

[1] casiopeia, 2008, RHEL5에서 rpm으로 mysql설치, http://blog.daum.net/_blog

/BlogTypeView.do?blogid=03rNC&articleno=14738860#ajax_history_home

[2]secretOfSh, 2009, Linux mysql install(리눅스 mysql 설치), http://secretofsh.tistory.com/36

[3] kwon37xi, 2004, RPM사용하기, http://kwon37xi.egloos.com/2510770

반응형