티스토리 뷰

mysql을 사용 하려면 mysql 사용자 계정을 등록하고 DB 를 만들어 줘야 합니다. 호스팅을 받으면 계정과,암호,DB명을 호스팅 업체에서 주겠지만 직접 서버를 돌리는 경우에 아래와 같이 하면 됩니다. 
( #은 리눅스 쉘 프롬프트이고, // 이후부분은 설명 입니다, mysql>은 마이스퀄 프롬프트입니다. ) 

1. mysql 설치 확인 : #rpm -qa | grep mysql 
2. mysql 설치 위치 확인 : #find / -name mysql 
3. mysql 시작 : #/etc/rc.d/init.d/mysqld start 

4. rpm으로 설치 했을때 mysql 의 위치 
/usr/bin ; mysql 실행 모듈,명령어 
/usr/lib ; mysql rpm 설치 디렉토리 
/usr/lib/mysql ; 데이타베이스 생성되는 디렉토리 ( DB create 할때 디렉토리로 추가됨) 
/etc/my.cnf ; mysql 설정 파일 
( ** rpm으로 php 와 mysql 을 설치한 경우와 소스를 컴파일한 경우 있는 위치가 틀립니다. **) 

5. 제일 먼저 해야 할일이 mysql root 의 패스워드 설정 입니다.초기에는 root 사용자에 패스워드가 설정되어 있지 않으므로(null 값) Enter password: 에 그냥 엔터를 입력하면 됩니다. 

#cd /usr/bin // mysql 명령어가 있는 디렉토리로 이동 합니다. 
#mysql -u root -p mysql // mysql 접속 
Enter password: 
Reading table information for completion of table and column names 
You can turn off this feature to get a quicker startup with -A 

Welcome to the MySQL monitor. Commands end with ; or g. 
Your MySQL connection id is 1 to server version: 3.23.49 

Type 'help;' or 'h' for help. Type 'c' to clear the buffer. 

mysql> //mysql 프롬프트 입니다. 

1) root 사용자의 패스워드를 myroot로 설정 해 보겠습니다. 
(** mysql 명령어는 모두 끝에 ; (세미콜론)을 붙여 주어야 합니다. **) 

mysql> update user set password=password('myroot') where user='root'; 
Querk OK, 2 rows affected (0.00 sec) 
Rows matched : 2 Changed : 2 Warnings : 0 

mysql>quit // mysql 을 끝내는 명령어 입니다. 쉘프롬프트로 돌아 가겠죠. 
(** 위 방법말고 #mysqladmin -u root -p password 'myroot' 해도 됩니다. ) 

변경된 root 사용자의 패스워드가 적용되기 위해서는 데이터베이스를 다시 불러와야 합니다. 
# mysqladmin -u root reload 

변경된 root 사용자 패스워드로 다시 mysql에 접속해 보겠습니다. Enter password: 에 변경된 패스워드인 myroot 를 입력합니다. 

$ mysql -u root -p mysql 
Enter password: 
Reading table information for completion of table and column names 
You can turn off this feature to get a quicker startup with -A 

Welcome to the MySQL monitor. Commands end with ; or g. 
Your MySQL connection id is 1 to server version: 3.23.49 

Type 'help;' or 'h' for help. Type 'c' to clear the buffer. 

mysql> 
2) 새로운 데이터베이스 생성하기 
새로운 데이터베이스를 생성하기 위해 셸 프롬프트 상에서 다음과 같이 입력합니다.생성할 데이터베이스 이름은 zboard 입니다. 

mysql>create database zboard; // zboard 를 만듭니다. 
Query OK, 0 rows affected (0.00 sec) 

3) zboard 에 계정 사용자(ID:zman)를 주고 암호(Password:zpass)까지 설정해서 한방에 끝내겠습니다. 
( ** insert문을 이용하는 것보다 grant 를쓰는것이 편합니다. **) 

mysql>GRANT ALL PRIVILEGES ON zboard.* TO zman@localhost IDENTIFIED BY 'zpass' WITH GRANT OPTION; 
Query OK, 0 rows affected (0.00 sec) 

4) 계정 등록을 확인해 보겠습니다. 
mysql>use mysql; // 참고로 mysql 은 사용자가 등록되는 DB 입니다.root 도 여기등록 됩니다. 
mysql>select * from user; // 위에서 만든 zman 이 사용자에 보여야 합니다. 

5) 끝내겠습니다. 
mysql>quit 

(** myroot,zboard,zman,zpass 는 제가 임의로 한 것이고 다른걸로 바꿔야 하는건 다 아시겠죠 ? ) 

이제 여기에 등록한 ID,DB,password를 제로보드 설치할때 주면 됩니다. 

6) 데이터 베이스 삭제 
mysql>drop database zboard; 

7) 사용자 삭제 
mysql>mysql> DELETE FROM user where user='zman'; 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함