6. DB (DataBase)
리눅스에서 제공하는 DB는 mysql, PostgreSQL, oracle, mSQL 등이 있다.
mSQl - 유닉스환경에서 클라이언트 / 서버 구조로 작동하는 관계형 데이터 베이스이다. oracle, sybase, informix를 비롯한 대부분의 사용 데이터베이스 시스템은 클라이언트/서버 구조를 가지고 있다. mSQL 은 개인용이나 연구용으로 무료로 배포되는 프로그램이지만 좋은 성능과 안정성으로 최근에 웹서버 구축을 위한 기반 데이터베이스 시스템으로도 많이 사용된다.
oracle - 오라클 서버는 진화된 대형 아키텍처를 지원한다. 오라클 서버의 가장 큰 특징 은 기존의 테이터베이스 시스템에 비하여 낮은 비용으로 분산 데이터시스템을 손쉽게 구축할수 있다는 것이다. 분산 데이터베이스 시스템을 구축하면 분산된 서버들 간에 자료 공유, 질의와 갱신이 가능하다. 이 같은 기능에 따라 완벽한 인트라넷 서버로서의 역할도 수행한다.
PostgreSQL - 객체 지향 기능을 가지고 있는 관계형 데이터베이스 시스템이다.
PostgreSQL의 전신인 postgre는 매우 다양한 연구와 여러 응용 결과를 구현하는 데 사용되어 왔으며, 금융상의 데이터 분석 시스템, 제트 엔진의 성능을 모니터링 하는 패키지 소행성의 운동을 추적하는 데이터베이스, 의학 정보 데이터 베이스, 몇 개의 지리정보 시스템등에 관련된 업무에 이용되었다. 이 postgre의 성능과 속도를 개선한 것이 바로 PostgreSQL 이다.
여기에서는 리눅스에서 기본제공하고 있고, 가장 많이 사용하는 mysql에 대해서 알아보도록 한다.
mysql은 공개된 관계형 데이터베이스로서 일반 상용 데이터베이스와 비교하여 크게 뒤질 것이 없는 매우 뛰어난 관계형 데이터베이스 이다. 다른 데이터베이스에 비하여 보안이나 각종 함수도 많아서 프로그램에 유용하다.
▶ mysql 명령
# mysql에 패스워드가 걸려있다고 가정한다 (만약 없다면 -u root -p를 빼고 명령실행)
mysql 실행
/usr/local/mysql/bin/safe_mysql &
mysql 중지
/usr/local/mysql/bin/mysqladmin -u root -p shutdown
mysql 접속
/usr/local/mysql/bin/mysql -u root -p db명
▶
mysqladmin 명령어
mysql을 관리하고, 상태를 확인하기 위한 명령어들로, 내부에서 사용하지 않고 외부에서도 mysql 을 제어할수 있도록 하는 명령들이다.
명 령 |
설 명 |
create <databasename> |
Create a new database |
drop <databasename> |
Delete a database and all its tables |
extended-status |
Gives an extended status message from the server |
flush-hosts |
Flush all cached hosts |
flush-logs |
Flush all logs |
flush-status |
Clear status variables |
flush-table |
Flush all tables |
flush-threads |
Flush the thread cache |
flush-privileges |
Reload grant tables (same as reload) |
kill id,id,... |
Kill mysql threads |
password <new-password> |
Create newpassword |
-p<old-password> \
password <new-password> |
Change old password to new-password |
ping |
Check if mysqld is alive |
processlist |
Show list of active threads in server |
reload |
Reload grant tables |
refresh |
Flush all tables and close and open logfiles |
shutdown |
Take server down |
status |
Gives a short status message from the server |
start-slave |
Start slave |
stop-slave |
Stop slave |
variables |
Prints variables available |
version |
Get version info from server |
< 표 6-1 mysqladmin 명령 일람표 >
mysqladmin -u root -p<password> <명령>
==========================================
mysqladmin <명령> ← mysql의 패스워드 없을때 |
< mysqladmin 명령어 사용방법 >
< 그림 6-1 mysqladmin status 명령 실행 예 >
status 출력 결과 |
설 명 |
uptime |
mysql이 실행된후 현재까지 실행된 시간을 초로 환산한 값 |
threads |
현재 mysql에 연결된 유저수 |
questions |
mysql 실행된후에 지금까지 요청된 커리수 |
slow queries |
--log-slow-queries[=filename] option으로 시작된 서버가
variables에 지정된 long-query_time seconds 시간보다 큰
쿼리 시간을 가진 요청수 |
opens |
서버가 실행되어서부터 현재까지 open되었던 tables수 |
Flush tables |
초기화 명령 (flush, reload, reflesh)이 사용되었던 횟수 |
open tables |
현재 open 되어있는 table 수 |
queries per second avg |
평균 초당 쿼리수 |
< 표 6-2 mysqladmin status의 실행 결과 출력 옵션 설명 >
|