db기본1(에러판별)

서버
   리눅스 : safe_mysqld
윈도우 : mysqld_shareware.exe
클라언트
   리눅스 : mysql
윈도우 : mysql.exe
서버가 실행중인지 확인하려면
ps aux |grep mysqld

데몬 실행법
1. 소스로 mysql인스톨시
cd /usr/local/mysql
./bin/safe_mysqld &
2. Rpm으로 mysql인스톨시
/etc/rc.d/init.d/mysqld start

mysql 서버에 접속하기
mysql -hlocalhost -u -p
========================================
접속시 에러 메시지 판별법
========================================
ERROR 2002 : Can't connetct to loacl mysql server through socket 'tmp/mysql.sock (61)
ERROR 2003 : Can't connetct to loacl mysql server on localhost(61)
     위의 에러가 발생시 -h옵션을 확인 또는 서버가 실행중인지 검사해 보자
     서버가 실행중이지 않는데 접속하려고 할때 발생한다
ERROR 1045 : Access denied for user : 'root@localhost' (Using password:YES)
패스워드가 틀렸거나 접속 id를 잘못 쓴경우

database 다루기
>show databases;
>use test
>show tables;
>create database new;
> drop database new;
create table if not exists result (
no int not null,
name varchar(8) not null,
korean int,
english int,
math int,
society int,
   science int,
   sum int,
   average float,
primary key (no),
index (name)
);
  
테이블에서 key
index key : 자주 검색대상이 되는 컬럼을 인덱스키로 지정 하여 검색속도 향상시킨다
unique key : 중복을 방지 한다 데이터에 중복된 데이터가 들어가려고 하면 에러를 발생하며
           입력되지 않는다
   (ex: 주민등록번호, 세금, 의료보험, 책의 바코드)
primary key : Unique 와 index 키를 동시에 가지는 컬럼이 많이 사용된다 두 기능을 동시에 가지는 컬럼속성을
            Primary key로 선언 데이터의 유일성과 속도를 높여 준다
==========================================
테이블 만들기 형식
==========================================
create table if not exists 테이블 이름 (
컬럼이름 데이터 타입
not null | null
default 초기값
auto_increment
primary key (키1, 키2...)
index (키1, 키2...)
)

Press ESC to close