캠핑과 개발

Mac에서 Mysql 설치하기

MAC2011. 7. 21. 16:57
 1. mysql-5.5.10-osx10.6-x86_64.dmg 를 다운받는다. (OS 버전에 맞춰)
 2. 마운트하여  mysql-5.5.10-osx10.6-x86_64.pkg 를 설치한다.
 3. mysql 설치 디렉토리는 /usr/local/mysql 이다.
 4. 부팅시 자동으로 시작되게 하려면 MySQLStartupItem.pkg를 추가로 설치한다.
     /Library/StartupItems/MySQLCOM 디렉토리에 설치됨 
     /etc/hostconfig 에 MYSQLCOM=-YES- 로 되어 있으며 자동으로 시작
   MYSQLCOM=-NO- 로 되어 있으면 자동으로 시작되지 않음
 5.  MySQLStartupItem 이 설치되어 잇을 때 서버 start 및 stop
     shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start 
     shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop 

 6.  MySQL.prefPane 을 더블클릭하면 시스템환경설정에 추가할 수 있음
      Pane 에서도 자동 시작을 설정할 수 있음 

 [encoding, characterset 적용]

 1. mysql 서버설정을 위한 configuration file 생성
     shell> cd /usr/local/mysql/support-files/ 
     shell> sudo cp my-small.cnf /etc/my.cnf

 2. innodb 로 설정

     [mysqld]
      default-storage-engine = INNODB
      # Uncomment the following if you are using InnoDB tables
      innodb_data_home_dir = /usr/local/mysql/data
      innodb_data_file_path = ibdata1:10M:autoextend
      innodb_log_group_home_dir = /usr/local/mysql/data
      # You can set .._buffer_pool_size up to 50 - 80 %
      # of RAM but beware of setting memory usage too high
      innodb_buffer_pool_size = 16M
      innodb_additional_mem_pool_size = 2M
      # Set .._log_file_size to 25 % of buffer pool size
      innodb_log_file_size = 5M
      innodb_log_buffer_size = 8M
      innodb_flush_log_at_trx_commit = 1
      innodb_lock_wait_timeout = 50

 3. encoding, characterset 서버 환경 설정에 적용 
     
  [mysqld]

  character-set-server=utf8
  collation-server=utf8_general_ci

 4. 트랜잭션 레벨 변경
     오라클의 기본 설정과 같이 READ-COMMITTED 로 적용한다.

[mysqld]
transaction_isolation = READ-COMMITTED

 5. 테이블 대소문자 구분 없이 세팅
     
[mysqld]
lower_case_table_names=1

 6. Auto Commit 설정
     클라이언트 접속시 디폴트는 autocommit=1 이다. 이것을 바꾸기 위해서는 설정파일에 다음과 같이 쓴다.
     0 은 autocommit 을 false 로 세팅한다.

[mysqld]
autocommit=0

 7. client connection characterset 설정
     클라이언트 컨넥션의 디폴트 characterset을 설정한다.

[client]
default-character-set=utf8


 [encoding 에 character set 적용]
 - 데이터 베이스 생성시에 적용 - 해당 데이터베이스에 테이블을 생성할 때 모두 적용됨

      CREATE DATABASE mydb
  DEFAULT CHARACTER SET utf8 
  DEFAULT COLLATE utf8_general_ci; 

 [encoding characterset 확인]
 mysql> use information_schema;
 mysql> select * from GLOBAL_VARIABLES where VARIABLE_NAME like '%CHARACTER%';
 mysql> select * from GLOBAL_VARIABLES where VARIABLE_NAME like '%COLLATION%';
 mysql> select * from GLOBAL_VARIABLES where VARIABLE_NAME like '%AUTOCOMMIT%';

 ※ "Can't get hostname for your address" 에러가 나오면 서버 설정을 해주던지 hosts 파일에 등록한다.
 1. [mysqld]
     skip-name-resolve

 2. mysql 서버 hosts 파일에 mysql 을 호출하는 클라이언트 ip 를 등록

 서버옵션확인
 shell>mysqladmin -uroot -ppassword variables

[출처] http://www.ahnseungkyu.com/60 

'MAC' 카테고리의 다른 글

맥용 유용한 사이트  (0) 2012.01.04
맥 라이언에서 패러럴즈가 실행이 되지 않을 경우  (0) 2011.07.26
[MAC] Mac 응용프로그램  (0) 2011.07.14
[MAC] Mac OS X hosts 파일 수정  (0) 2011.07.14
MAC 단축키  (0) 2011.06.30