MySQL 설치 및 utf-8 인코딩 설정에 대하여 포스팅을 해보았습니다.
2014/12/15 - [개발에필요한연동법/리눅스서버구축] - CentOS 에서 MySQL 설치 및 UTF-8 설정하여 한글깨짐 현상 해결하기
윈도우는 보통 자동으로 대소문자 구분을 해주는 반면,
리눅스 환경(CentOS, Ubuntu 등..) 에서는 대소문자 구분이 되지 않을경우
별도로 설정을 추가해주어야 합니다.
예를 들어보고자 test DB의 테이블명 'test_table' 이라는 테이블을 생성 후
대소문자 설정을 해보도록 하겠습니다.
MySQL 접속 후 test DB내에 테이블 생성을 해보도록 하겠습니다.
[root@localhost local]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 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> use test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> create table test_table ( -> idx int, -> title varchar(50) -> ); Query OK, 0 rows affected (0.02 sec) mysql>
테이블 생성이 완료되었다면 테이블명을 대문자로 지정하여 SELECT 해보도록 하겠습니다.
mysql> SELECT * FROM TEST_TABLE; ERROR 1146 (42S02): Table 'test.TEST_TABLE' doesn't exist mysql>
test_table 테이블을 찾을수 없다는 에러메시지가 출력이 되는군요.
그렇다면 대소문자 구분에 대한 설정값이 어떻게 되어있는지 확인해보도록 하겠습니다.
mysql> show variables like 'lower_case_table_names'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_table_names | 0 | +------------------------+-------+ 1 row in set (0.00 sec) mysql>
Value 값이 0일 경우 : 대소문자 구분(O)
Value 값이 1일 경우 : 대소문자 구분(X)
즉, Value값이 현재 0이므로 대소문자 구분을 하게 되있으므로
대문자로 테이블 조회시 존재하지 않는 테이블입니다라는 메시지가 출력된 것입니다.
그렇다면 대소문자 구분을 하지 않기 위해
Value값이 1로 변경을 해주기 위하여 다음 작업을 진행하도록 합니다.
이전 MySQL utf-8 인코딩 설정할때 수정해준 my.cnf 파일을 이용하여
대소문자 구분 설정을 해줘보도록 하겠습니다.
[root@localhost local]# vi /etc/my.cnf
[mysqld]하단에 다음 코드를 추가해주도록 합니다.
lower_case_table_names = 1
추가가 완료되었다면 mysql 데몬을 재시작하여
다시 한번 대문자로 test_table을 조회해보도록 하겠습니다.
[root@localhost local]# service mysqld restart mysqld 를 정지 중: [ OK ] mysqld (을)를 시작 중: [ OK ] [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> use test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> SELECT * FROM TEST_TABLE; Empty set (0.00 sec) mysql>
테스트 결과 정상적으로 대문자로 테이블 선언을 하였는데도
정상적으로 조회가 되는 것을 확인 할 수 있습니다.
by 개발로짜
가상머신에 설치된 CentOS에 SVN Server 구축 후 이클립스로 접속하기 (0) | 2014.12.20 |
---|---|
CentOS 몽고DB 다운로드 및 환경설정 후 접속테스트까지 간단하게 알아보기 (1) | 2014.12.19 |
CentOS 에서 MySQL 설치 및 UTF-8 설정하여 한글깨짐 현상 해결하기 (0) | 2014.12.15 |
CentOS tomcat-connector를 이용한 아파치 + 톰캣 간단 연동법 알아보기 (17) | 2014.12.11 |
CentOS wget을 이용하여 Apache 2.4 다운로드 및 서버 실행 (방화벽해제 포함) (1) | 2014.12.10 |