MySQL 문자셋 지정

Linux & Solaris 2009.08.04 05:29 posted by JP™

euckr 로 지정 할 경우 아래처럼 /etc/my.cnf 파일을 수정하면 되고
utf-8 을 사용하고 싶으면 euckr 을 utf8 로 수정하면 된다.

[client]
default-character-set=euckr

[mysqld]
init_connect = SET collation_connection=euckreuckr
init_connect = SET NAMES euckreuckr(& utf8)
default-character-set=euckr
collation-server=euckr
default-collation=euckr_korean_ci

[mysqldump]
default-character-set=euckr

[mysql]
default-character-set=euckr

mysql 리스타트

<확인>
mysql> show variables like 'c%';



mysql processlist 에 알수없는 호스트 관련 프로세스가 계속 떠 있으면서 속도가 느려질 경우


vi /etc/hosts 파일에 해당 호스트 IP를 추가하고
mysqladmin -uroot -p flush-host 로 적용시켜 준다.

pear DB 설치 및 사용법

PHP 2009.08.04 04:59 posted by JP™


Pear 설치
/usr/local/php/bin/pear install Pager
/usr/local/php/bin/pear install DB


*기본설정*

<?php
 // 데이터베이스 정보 설정
 DEFINE("DB_TYPE", "MySql");
 DEFINE("DB_HOST", "localhost");
 DEFINE("DB_PORT", "3306");
 DEFINE("DB_USER", "database");
 DEFINE("DB_PASS", "password");
 DEFINE("DB_NAME", "shoplinker");

 // PEAR DB_Pager 로드
 include_once "DB/Pager.php";


 // DNS 문자열 설정
 $dsn_str = DB_TYPE . "://" . DB_USER . ":" . DB_PASS . "@" . DB_HOST . ":" . DB_PORT . "/" . DB_NAME;

 // 디비 접속
 $db = DB::connect($dsn_str);

 if(DB::isError($db)){
  // 접속 에러시
  echo $dsn_str . "<BR>\n";
  echo $db->getMessage();
  exit;
 }

 


 /*사용법*/

 // Insert
 $fields_values = array(
  'id'  => $id,
  'content' => $content
  );

 $res = $db->autoExecute($table_name, $fields_values, DB_AUTOQUERY_INSERT );

 

 // Update
 $fields_values = array(
  'id'         => $email
 );
 $res = $db->autoExecute( $table_name, $fields_values, DB_AUTOQUERY_UPDATE, "id = '$id'"); //<- 마지막 인자는 where구문.


 // Another Insert/Update
 $sql = "여기에 insert 또는 update 또는 delete구문";
 $res =& $db->execute($db->prepare($sql));


 // 최대값/최소값/카운터(count(),max(),min() or Only One Value-$rst[0][0])
 $rst = $db->getOne("select count(id) from TEST where name='$name'" );


 // 1열 SELECT
 $data =& $db->getRow("QUERY",2);
 echo $data[FIELD_NAME] . "<br>";


 // 1행 SELECT
 $data =& $db->getCol("select * from test");
 for($i=0;$data[$i];$i++){ echo $data[$i] . "<br>"; }


 // 복수자료 뽑아오기
 $res =& $db->query("select no from $table_name" );
 
 if (PEAR::isError($res)){
  die($res->getDebugInfo());
 }

 while($data =& $res->fetchRow(DB_FETCHMODE_ASSOC)){
  echo $data[FIELD_NAME];
 }


 // limit 구현
 $db->setFetchMode(DB_FETCHMODE_ASSOC);
 $res =& $db->limitQuery('SELECT * FROM $table_name', 0, 5);

 for($i=0; $row =& $res->fetchRow(DB_FETCHMODE_ASSOC); $i++){
  echo "date :  " . $row[TIME] . "&nbsp&nbsp&nbspID : " . $row[PCLE_ID] . "<br>";
 }


 // CLOB 데이터형을 조건 검색할때..
 select * from 테이블 where DBMS_LOB.INSTR(필드명,'검색단어')>0

 $db->disconnect();

'PHP' 카테고리의 다른 글

Daum 자동 로그인 만들기..  (1209) 2009.08.06
PHP 이클립스 사용하기  (0) 2009.08.04
cake 프레임워크 사용법  (376) 2009.08.04
pear DB 설치 및 사용법  (3) 2009.08.04

TAG DB, MYSQL, pearDB, php
  1. Commented by timberland hombre at 2012.12.23 09:18

    Le disc-jockey passé à tabac par plusieurs hommes dans la nuit de la Saint-Sylvestre pour avoir refusé l'entrée d'une soirée privée à l'un d'entre eux au Blanc-Mesnil (Seine-Saint-Denis), http://timberlandbotases.com timberland españa catalogo 2011, est décédé mercredi soir, http://timberlandbotases.com botas timberland mujer, a indiqué le parquet de Bobigny, http://timberlandbotases.com timberland botas.Related articles:


    http://onetongorilla.com/2005/03/dog-lays-egg.html#comments http://onetongorilla.com/2005/03/dog-lays-egg.html#comments

    http://www.i5wan.com/plus/view.php?aid=93577 http://www.i5wan.com/plus/view.php?aid=93577

  2. Commented by Timberland Online at 2012.12.24 12:57

    you never know, http://www.timberlandbaratas.com zapatos timberland!
    This mission is to perform "home improvements" to the space station, http://www.timberlandbaratas.com Timberland, the only airline to disappoint Wall Street was Alaska Air Group (Alaska Airlines and Horizon Air), http://www.timberlandbaratas.com Mujer Timberland.But ont fracturé la porte arrière de la boutique, http://www.timberlandbaratas.com timberland.
    Related articles:


    http://www.lyrics.kr/20 http://www.lyrics.kr/20

    http://www.articlesdb.net/submitarticles.php?act=edit&id=1955308 http://www.articlesdb.net/submitarticles.php?act=edit&id=1955308

    http://www.moozine.net/696 http://www.moozine.net/696

  3. Commented by barato timberland at 2012.12.25 12:44

    Johan Vande Lanotte a mis fin jeudi à sa "mission de conciliation" entre les formations politiques de Belgique, http://www.timberlandbaratas.com outlet timberland, qui ne parviennent pas à s'entendre sur la formation d'un gouvernement, http://www.timberlandbaratas.com timberland niños, a annoncé le palais royal, http://www.timberlandbaratas.com timberland. La Belgique est privée de gouvernement depuis 207 jours et elle est dirigée par un cabinet chargé de gérer les affaires courantes, http://www.timberlandbaratas.com Timberland shops. Johan Vande Lanotte s'était vu confier cette mission en octobre par le roi Albert II, http://www.timberlandbaratas.com timberland españa. Les deux principaux partis flamands n'ont pas approuvé avant la date-butoir fixée à mercredi le document qu'il avait élaboré pour servir de base à des négociations, http://www.timberlandbaratas.com botas timberland.Related articles:


    http://smaragd.tistory.com/50 Les services du renseignement afghans ont affirmé mercredi avoir déjoué un complot visant à assa

    http://dokim.tistory.com/guestbook?page=2 Eminem a définitivement fait son retour au cinéma

솔라리스(SOLARIS) APM 설치

Linux & Solaris 2009.08.01 21:08 posted by JP™


※ 솔라리스 설치후 기본적인 설정

- 기본 셸을 bash로 변경
$ vi /etc/passwd
아래 라인 수정
root:x:0:1:Super-User:/:/bin/bash

 

- /etc/profile 환경설정
$ vi /etc/profile
아래 라인 수정 및 추가
alias ll="ls -alF"
LANG=ko.UTF-8; export LANG
stty -istrip -parenb cs8
 
PS1="[\h] \W\\$ "; export PS1
EDITOR=vi; export EDITOR
CC=gcc; export CC
CPP="gcc -E"; export CPP
PATH=/usr/local/bin:/usr/sfw/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ccs/bin; export PATH
LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/ucblib:/usr/ccs/lib:/usr/sfw/lib:/usr/local/xml/lib; export LD_LIBRARY_PATH

$ sync
$ sync
$ reboot (리부팅)

 

-- gcc 헤더파일 수정하기(컴파일이 제대로 이루어 지지 않을경우)

$ vi /usr/local/lib/gcc-lib/i386-pc-solaris2.10/3.3.2/install-tools/mkheaders.conf

SHELL=/bin/sh
SYSTEM_HEADER_DIR="/usr/include"
OTHER_FIXINCLUDES_DIRS=""
FIXPROTO_DEFINES=""
STMP_FIXPROTO=""
STMP_FIXINC="stmp-fixinc"

$ /usr/local/lib/gcc-lib/i386-pc-solaris2.10/3.3.2/install-tools/mkheaders



설치가 되지 않는 패키지가 있다면 www.sunfreeware.com  에서 다운로드 후 추가 해 주어야 한다.
솔라리스는 리눅스와 다르게 기본적으로 설치되어 있지 않은 페키지들이 많이 있다.
대표적으로 make, top, gcc, c++ 등 필수 패키지가 실행되지 않으면 설치를 해 줘야 한다.

$ pkgadd -d 패키지 명



-- APM 컴파일 설치

www.apache.org
www.php.net
www.mysql.com

위 사이트를 통해 각 소스를 다운로드 받는다.

$ tar xvf http_*
$ tar xvf php_*
$ tar xvf mysql_*

$ gnuzip http_*
$ gnuzip php_*
$ gnuzip mysql_*



-- mysql 컴파일
$ tar xvf http_*
$ tar xvf php_*
$ tar xvf mysql_*
$ ./configure --prefix=/usr/local/mysql --enable-shared

$ groupadd mysql
$ useradd -g mysql mysql
$ chown -R mysql /usr/local/mysql
$ chgrp -R mysql /usr/local/mysql
 

-- apache 컴파일
$ cd ../http_*
$ ./configure --prefix=/usr/local/httpd --enable-so  --enable-rewrite --with-mpm=prefork

※ apr 관련 에러 발생시  --with-included-apr 옵션 추가

$ make
$ make install

-- php 컴파일


※ 필수
OpenSSL 설치
www.sunfreeware.com  에서 openssl 다운로드후 pkgadd -d 를 통해 설치
※ 소스컴파일시 일부 연동이 안됨(curl / php 컴파일시).


※ 필수(사용시)
Curl 설치

다운로드 : http://curl.haxx.se/download.html

$ ./configure --disable-ipv6 --with-ssl=/usr/local/ssl
$ make
$ make install

※ 필수
www.sunfreeware.com  에서 설치될 페키지(freetype, jpeg, libpng, xml2, zlib, ttf 등) 을설치해준다.

 

※ 필요시 추가
0.4 JPEGSRC 설치

다운로드 : http://graphics.cs.uni-sb.de/NMM/Download/external/jpegsrc.v6b.tar.gz


$ ./configure --enable-shared --enable-static
$ make
$ make test
$ make install
$ make install-lib
$ make install-headers


※ 필요시 추가
freetype, libiconv, libpng, xml, tiff 설치
$ ./configure
$ make
$ make install

 


$ ./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/conf \    #php.ini 위치 지정
--with-mysql=/usr/local/mysql \
--with-apxs2=/usr/local/httpd/bin/apxs \
--enable-sysvshm=yes \
--enable-sysvsem=yes \
--enable-debug=no \
--enable-ftp \
--enable-mbstring \
--enable-sockets \
--enable-exif \
--enable-wddx \
--enable-bcmath \
--enable-calendar \
--enable-soap \
--with-openssl=/usr/local/ssl \
--with-iconv \
--with-libxml-dir \
--with-curl=/usr/local \
--with-zlib-dir \
--with-png-dir \
--with-jpeg-dir \
--with-ttf \
--with-freetype-dir \
--with-gd \
--enable-gd-native-ttf


$ make
$ make install
$ cp php.ini-dist /usr/local/httpd/conf/php.ini

 


$ vi /usr/local/apache/conf/httpd.conf

LoadModule php5_module libexec/libphp5.so <--- 있는지 확인

내용추가
DirectoryIndex index.html index.htm index.php index.phtml
AddType application/x-httpd-php .php .html .htm .phtml .php3 .php4
AddType application/x-httpd-php-source .phps


$ /usr/local/httpd/bin/apachectl start


# apache 홈 디렉토리 변경시, 403에러 대처법
httpd.conf 파일을 열어서


<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

Deny from all (삭제 : 기본설정임)
Allow from all (추가)


  1. Commented by outlet timberland at 2012.12.25 16:10

    FlightAndRoom's mission is to offer the best low prices on airline tickets, hotel reservations, car rentals, holiday packages and cruises. Through our partnerships with leading travel companies, http://www.timberlandbaratas.com Timberland shops, we can get you low prices that can't be found anywhere else, http://www.timberlandbaratas.com timberland niños.How does it work, http://www.timberlandbaratas.com Timberland Online? Our partners allow us access to their unsold inventory - empty seats on flights, empty hotel rooms, and unrented cars - at big savings. Our system compares prices from over 455 airlines worldwide, 200 hotel companies (representing approximately 39, http://www.timberlandbaratas.com barato timberland,000 properties), http://www.timberlandbaratas.com timberland españa, and 44 car rental companies (representing approximately 17,275 properties), http://www.timberlandbaratas.com timberland.Related articles:


    http://www.networkpark.com/122 Un détenu de 24 ans a été retrouvé grièvement blessé à la gorge dans sa cellule de la maison

    http://luuvish.org/183 Le gendarme boursier américain