TagCloud

Monday, October 22, 2012

MySQL Installation


개인적으로 Oracle 인수 이후로 MySQL 보다는 PostgreSQL 을 선호함..


참고사항 : MySQL 5.5 이상부터는 cmake 로 설치 필요. CentOS 6.3 에서 설치를 기준으로 설명함
-> 필요시 : yum install cmake

1. Download
- wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.28.tar.gz/from/http://ftp.jaist.ac.jp/pub/mysql/

2. 필요시 Dependency Library 설치
- yum install zlib curl
- yum install gcc g++ cpp gcc-c++
- yum install openssl openssl-devel
- yum install libtermcap-devel ncurses-devel libc-client-devel bzip2-devel
- yum install bison
- yum install make # CentOS 6.3 에는 make 가 default 아님.

3. 필요시 계정추가
- useradd mysql

4. 압축 해제 후, cmake 실행 ( 설치 경로 지정 )
- cmake -DCMAKE_INSTALL_PREFIX=/srv/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DMYSQL_DATADIR=/srv/mysql/data  -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/srv/mysql/mysql.socket -DMYSQL_TCP_PORT=3306

4. 설치
- make
- make test(필요시)
- make install

5. mysql 설치경로로 이동 후, Default DB 설치 ( mysql 홈경로가 아닐경우 Fatal - 오류 메세지가 나올 수 있음)
- ./scripts/mysql_install_db --user=mysql --datadir=/srv/mysql/data

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:

/srv/mysql/bin/mysqladmin -u root password 'new-password'
/srv/mysql/bin/mysqladmin -u root -h vm00 password 'new-password'

Alternatively you can run:
/srv/mysql/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 /srv/mysql ; /srv/mysql/bin/mysqld_safe &

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

Please report any problems with the /srv/mysql/scripts/mysqlbug script!


6. 필요시 설정파일 복사
- cp /srv/mysql/support-files/my-medium.cnf /etc/my.cnf
- cp /srv/mysql/support-files/mysql.server /etc/init.d/mysqld

7. mysql 실행
- /srv/mysql/bin/mysqld &

8. mysql 보안 설정 실행
/srv/mysql/bin/mysql_secure_installation

9. root 접속 확인
/srv/mysql/bin/mysql -uroot -p


10. 외부접속 권한 추가(필요시 - 주:아래 예제는 root 에 모든 권한을 허용하는 예제이므로 실 운영시 주의)
- mysql> use mysql;
- mysql> grant all privileges on *.* to 'root'@'%' identified by 'root의 패스워드';
- mysql> select host, user, password from user;
- mysql> flush privileges;

11. daemon 등록
- chkconfig --add mysqld

12. 방화벽 포트 허용
- iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
- service iptables save
- service iptables restart