캠핑과 개발


http://dev.mysql.com 에서 다운로드 후 설치

mysql 5.1 바이너리 설치

[바이너리 버전 설치 순서]
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &

이제 기본 데이터베이스 설치를 위해 아래의 코드 실행. script 디렉토리 안에서 mysql_install_db를 실행하니 아래와 같이 FATAL ERROR가 발생했다. 
그러므로 아래 빨간 색으로 표시된 것처럼 mysql의 탑 디렉토리에서 실행해야 성공한다.

[root@localhost bin]# cd ../scripts
[root@localhost scripts]# ls
mysql_install_db
[root@localhost scripts]# ./mysql_install_db 

FATAL ERROR: Could not find ./bin/my_print_defaults

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

[root@localhost scripts]# pwd
/usr/local/mysql/scripts
[root@localhost scripts]# cd ..
[root@localhost mysql]# ./scripts/mysql_install_db 
Installing MySQL system tables...
090720 14:01:07 [Warning] Forcing shutdown of 2 plugins
OK
Filling help tables...
090720 14:01:07 [Warning] Forcing shutdown of 2 plugins
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:

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

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

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

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

The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/

이제 기본 DB(mysql, test)의 설치가 끝났다. mysql 디렉토리를 보면 data라는 새 디렉토리가 생성되었을 것이다.

mysql 실행
mysql 게정으로 로긴 후
mysql]$ /usr/local/mysql/bin/mysqld_safe &

mysql 종료
mysqladmin -u root -p shutdown

root로 접속하기 (여기서 root는 시스템의 root계정이 아니라, mysql의 관리계정이다)
처음 설치시 root의 패스워드는 없다.

사용형식) mysql -u MySQL계정명 -p 접속할데이터베이스명
mysql]$ mysql -u root -p mysql

database내 테이블 조회
mysql> show tables;

테이블 스키마 조회
mysql> desc <테이블명>;


자동 시작 등록

#!/bin/sh
vi /etc/rc.d/rc.local

/usr/local/mysql/bin/mysqld_safe &

 

- 데몬이 무사히 실행됐다면 서버 시작시에 자동실행되도록 한다.
  # cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d
  # ln -s ../init.d/mysql.server /etc/rc.d/rc0.d/K01mysql
  # ln -s ../init.d/mysql.server /etc/rc.d/rc3.d/S90mysql

 
/var/run/mysqld/mysqld.pid를 생성하지 못할경우
cd /var/run
mkdir mysqld
chown mysql mysqld
chgrp mysql mysqld 



 

'DEVELOPMENT > Linux' 카테고리의 다른 글

linux shell 스크립트  (0) 2012.01.13
Fedora 16 | systemctl - 서비스 관리 명령어  (0) 2011.12.01
ssh 접속 설정.  (0) 2011.11.29
linux 방화벽 열기  (0) 2011.11.29
sftp root 계정 접속 설정  (0) 2011.07.27