본문 바로가기
Linux/APM

[CentOS7] mysql 5.1.x 설치하기

by aegypius 2020. 4. 24.
728x90
반응형

  mysql 5.x는 mariadb 5.x로 대체할 수 있지만 mysql 5.1을 위해서 mariadb 5.1~5.3을 설치하는 것보다 mysql 5.1.73을 설치하기로 했다.

  서버 OS : CentOS-7-x86_64-Minimal-1908.iso (소스 : http://vault.centos.org/)
  DB : mysql-5.1.73.tar.gz (소스 : http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.1/

  프로그램은 위의 링크가 아니더라도 구글 등에서 검색하면 많이 보인다. centos를 최소버전으로 설치했기 때문에 필요한 유틸을 직접 설치해야 한다.

# yum install wget
# yum install net-tools (ifconfig)
# yum install gcc gcc-c++ (컴파일 설치)

  적당한 디렉토리에 mysql을 다운 받자. 새로만든 계정(pius)의 하위 디렉토리에 소스를 다운받았다. 설치전에 mysql을 위한 사용자와 그룹을 생성하자.

# groupadd mysql
# useradd -g mysql mysql
# pwd
/home/pius/pius
# wget http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz

 

  이제 압축을 풀고 컴파일을 해야한다...

# tar xvf *gz (tar xvf mysql-5.1.73.tar.gz과 동일)
# cd mysql-5.1.73
# ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --sysconfdir=/etc --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --without-debug --enable-assembler --with-charset=utf8 --with-plugins=innobase --with-extra-charsets=all

 

  혹시 No curses/termcap library found 오류가 발생한다면 아래와 같이 해당 라이브러리를 설치한 후에 configure 과정을 다시 거쳐야 한다.

# yum install libtermcap-devel ncurses-devel

 

  character set을 euc-kr로 설정하고자 한다면 위의 configure 옵션에서 --with-charset=utf8을 euckr로 변경하고, extra-charsets는 삭제하자. 이제 컴파일, 설치를 하자.

# make
# make install

  오류없이 설치가 끝났으면 컴파일 했던 디렉토리의 하위에 support-files라는 디렉토리가 생성되었을 것이다. 이곳에 위치한 my-medium.cnf를  /etc에 my.cnf라는 이름으로 복사해두자.

# cp ./support-files/my-medium.cnf /etc/my.cnf

  /etc/에 이미 my.cnf가 있더라도 overwrite하자. 이제 아래와 같이 mysql_install_db를 실행시켜야 한다. mysql이 설치된 디렉토리(/usr/local/mysql)의 하위인 bin에서 찾을 수 있다.

# /usr/local/mysql/bin/mysql_install_db

  아래와 같은 메시지가 출력될 것이다.

[root@localhost mysql-5.1.73]# /usr/local/mysql/bin/mysql_install_db
Installing MySQL system tables...
200424 16:49:40 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
200424 16:49:40 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
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:

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

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

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

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

  mysql_install_db가 실행되면 configure 옵션에서 localstatedir로 지정했던 디렉토리(/usr/local/mysql/data)가 생성된다. 아래와 같이 새로 생성된 디렉토리(data)의 소유권을 mysql 계정과 그룹에 주어야 한다.

# chown -R mysql.mysql /usr/local/mysql/data

  이제 mysql을 실행시킨 후 mysql의 root 암호를 설정하자. mysql.server는 처음 mysql를 설치하기 위해서 압축을 풀고 컴파일 했던 디렉토리의 support-files에 위치하고 있다. 이 파일을 mysql의 설치디렉토리의 bin에 복사해 두고 실행시켜도 무방하다.

***** mysql의 최초실행 *****
# cp support-files/mysql.server /usr/local/mysql/bin
# chmod 755 /usr/local/mysql/bin/mysql.server
# /usr/local/mysql/bin/mysql.server start
Starting MySQL SUCCESS!
#
#
***** root 암호설정 *****
# /usr/local/mysql/bin/mysqladmin -u root password 'rootpassword'
#

  rootpassword에 원하는 암호를 넣어서 설정할 수 있다. 암호 설정이 성공하더라도 아무런 메시지도 출력되지 않는다. 이제 mysql을 실행시켜보자. 아래와 같다.

# /usr/local/mysql/bin/mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost /]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.73-log Source distribution

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

  3번째 줄과 같이 -u 옵션으로 계정과 -p 옵션으로 계정의 비밀번호를 입력하면 정상적으로 실행된다.

  mysql을 서비스 데몬에 추가하면 조금 편리하다. 아래와 같다.

# pkill mysqld
# cp -a /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
# chkconfig mysqld on
# service mysql start
Starting MySQL. SUCCESS!
# systemctl start mysqld
# systemctl status mysqld

  

728x90
반응형

댓글