이번 CentOS 6.5에다가 MySQL설치를 간단하게 yum을 이용해보도록 하겠습니다.
MySQL 다운로드는 사이트 접속하여 로그인하고 여러개의 파일들을 다운로드 받아야해서 ;;;
제일먼저 mysql 인스톨을 합니다.
[root@localhost local]# yum -y install mysql*
설치가 완료되었다면 MySQL 데몬을 실행을 해보도록 하겠습니다.
[root@localhost local]# service mysqld start MySQL 데이타베이스 초기화 중: Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ] mysqld (을)를 시작 중: [ OK ]
정상적으로 데몬이 실행이 되었다면
MySQL 접속테스트를 진행해보겠습니다.
※ 초기 root계정의 패스워드는 없으므로 Enter password부분은 그냥 Enter키를 눌러서 넘겨주도록 합니다.
[root@localhost local]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
이제는 MySQL의 인코딩 타입을 확인해보도록 합니다.
mysql> show variables like 'c%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | | collation_connection | latin1_swedish_ci | | collation_database | latin1_swedish_ci | | collation_server | latin1_swedish_ci | | completion_type | 0 | | concurrent_insert | 1 | | connect_timeout | 10 | +--------------------------+----------------------------+ 14 rows in set (0.00 sec) mysql>
인코딩 확인 결과 대부분의 character_set이 latin1로 설정이 되어있습니다.
이럴경우 한글깨짐 현상이 발생할 확률이 크므로
latin1인코딩 타입을 utf8 타입으로 변경해주도록 하겠습니다.
리눅스 환경일 경우 my.cnf 파일을 수정해주시면 되겠고
윈도우 환경은 my.ini 파일을 수정해주시면 되겠습니다.
저는 리눅스 환경이므로 my.cnf 파일을 수정해보도록 하겠습니다.
[root@localhost local]# vi /etc/my.cnf
하단 각 [xxxx] 선언이 되있는 하단에 각 인코딩 설정코드들을 추가해주도록 합니다.
[xxxx] 자체가 없다면 [xxxx] 부분도 같이 추가해주도록 합니다. ^^
[client] #추가 default-character-set = utf8 [mysqld] #추가 init_connect="SET collation_connection = utf8_general_ci" init_connect="SET NAMES utf8" default-character-set = utf8 character-set-server = utf8 collation-server = utf8_general_ci [mysqldump] #추가 default-character-set = utf8 [mysql] #추가 default-character-set = utf8
위 인코딩 설정을 모두 잡아주었다면 데몬을 재시작 후
다시 한번 인코딩타입을 재확인해보도록 하겠습니다.
[root@localhost local]# service mysqld restart mysqld 를 정지 중: [ OK ] mysqld (을)를 시작 중: [ OK ] [root@localhost local]#
[root@localhost local]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show variables like 'c%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | | collation_connection | utf8_general_ci | | collation_database | utf8_general_ci | | collation_server | utf8_general_ci | | completion_type | 0 | | concurrent_insert | 1 | | connect_timeout | 10 | +--------------------------+----------------------------+ 14 rows in set (0.00 sec) mysql>
위처럼 설정 후 MySQL의 인코딩타입을 확인해 본 결과
모든 인코딩이 utf8 환경으로 변경 된 것을 확인 할 수 있었습니다.
MySQL 한글 깨짐현상 문제에 대하여 해결이 되시길... ^^
by 개발로짜
CentOS 몽고DB 다운로드 및 환경설정 후 접속테스트까지 간단하게 알아보기 (1) | 2014.12.19 |
---|---|
리눅스환경에서 MySQL 대소문자 구분을 하지 않기위한 설정방법 알아보기 (0) | 2014.12.15 |
CentOS tomcat-connector를 이용한 아파치 + 톰캣 간단 연동법 알아보기 (17) | 2014.12.11 |
CentOS wget을 이용하여 Apache 2.4 다운로드 및 서버 실행 (방화벽해제 포함) (1) | 2014.12.10 |
CentOS 6.5 - Tomcat7 다운로드 + 서버 실행 및 방화벽 해제 알아보기 (0) | 2014.12.09 |