본문 바로가기

MySQL

Mysql UTF8 설정 * Mysql 5.7 기준 #vi /etc/my.cnf 아래 설정 삽입 [mysql] default-character-set = utf8 [mysqld] character-set-client-handshake=FALSE init_connect="SET collation_connection = utf8_general_ci" init_connect="SET NAMES utf8" character-set-server = utf8 collation-server = utf8_general_ci [client] default-character-set = utf8 더보기
Mysql utf8 collation 문제 서버환경: CentOS7, mysql 5.7 mysql의경우 같은 utf8이라도 Collation에 있어서, utf8_unicode_ci와 utf8_general_ci의 중돌 문제가 있음. utf8_unicode_ci는 정확성이 좋으나 성능이 떨어지고, utf8_general_ci은 반대로 성능이 우수하다. default는 utf8_general_ci로 변경했으나 만약 문제가 있으면... > Alter Database DB명 Collate utf8_general_ci로 DB 초기 값을 설정을 변경한다. mysql의 설정 값을 보려면, > show variables like 'c%'; 더보기
Mysql 데이터 원격 복제(replication) master 서버의 mysql 데이터를 slave 서버로 원격 복제하고 싶은 경우가 있는데, 이때 활용할 수 있음. 다만, 오랜기간 실험한 것이 아니라 다소 불안정할 수 있는 점 양해 바랍니다^^ 서버환경: CentOS7, mysql 5.7 [Master 서버 설정] 1. 설정 # vi /etc/my.cnf 에 아래 내용 추가 log-bin=mysql-bin server-id=1 FLUSH TABLES WITH READ LOCK; change master to master_host ='123.123.123.123', master_port =3306, master_user ='유저아이디', master_password ='패스워드', master_log_file ='mysql-bin.000002', mas.. 더보기
MySql 2개 테이블 JOIN 업데이트 / 삭제 mysql 2개의 테이블을 특정 칼럼을 기준으로 연동하여 업데이트 또는 삭제하기 위한 쿼리 1. 테이블 업데이트 update TBL1 a inner join TBL2 b on a.col1 = b.col1 set a.col2 > 1 2. 테이블 삭제 [방법1] delete a from TBL1 a inner join TBL2 b on a.col1 = b.col1 where b.col2 = 'AAA' [방법2] delete from a using TBL1 a inner join TBL2 b on a.col1 = b.col1 where b.col2 = 'AAA' 더보기
MySql Fulltext 검색 MySql 5.7 이상은 InnoDB Fulltext Search에 대한 파서를 지원함. 1. mysql 시스템 변수 설정 검색시 문장 또는 단어를 잘라서 분석하기 위한 음절의 단위를 설정하기 위해 # vi /etc/my.cnf 아래 한 줄을 추가함. ngram_token_size=2 (토큰 값은 1~10, 기본 설정은 2) 2. Fulltaxt 인덱스 생성 - table 생성시 mysql> create table 테이블명 (id int auto-increment not null primary key, 칼럼1 varchar(50), 칼럼2 varchar(255), fulltext index ngram_idx(칼럼1) with parser ngram) engine=innodb character set ut.. 더보기
iptable 설정 리눅스 서버가 웹서버, DB서버 등을 원격으로 서비스 하되, 서비스 별로 원격 접속 허용을 제한하기 위한 iptable 설정방법 CentOS 7에서 테스트 1. firewall 중지 #systemctl stop firewalld #systemctl mask firewalld 2. iptable 설치 및 구동 #yum install iptables-servieces -y #systemctl enable iptables #systemctl start iptables 3. iptable 설정 # vi /etc/sysconfig/iptables # sample configuration for iptables service # you can edit this manually or use system-config-.. 더보기
MySql 5.7 설치 Mysql 5.7 설치 [CentOS 7 서버에 설치함] 1. 기존 설치된 mariadb 삭제 (참고로 mariadb도 성능이 매우 우수함) # yum remove mariadb* # rpm -qa | grep mariadb 2. 설치 # yum update # yum -y install http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm #rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 1로 순차적으로 바꿔서 적용해봄 *** root 패스워드 에러시 /etc/my.cnf skip-grant-tables 더보기
mysql-connector-java 설치 [CentOS 7] [자바설치] 1. rpm 다운로드 2. yum localinstall ~.rpm 3. java -version, javac -version 확인 [mysql-connector설치] 1. mysql-connector-java~~.jar 파일 복사 2. /usr/java/jre/lib/ext 아래 폴더로 복사 더보기