인디노트

Centos 7 - 데이타베이스(MySql) 설치 본문

개발 플랫폼 및 언어

Centos 7 - 데이타베이스(MySql) 설치

인디개발자 2018. 4. 25. 14:09

Centos7 부터는 데이타베이스가 Mariadb로 바뀌었습니다.

그래서 MySql을 yum 으로 바로 설치가 불가능합니다.

때문에 아래 명령을 차례로 입력하여 줍니다.

1
2
3
4
5
6
7
8
9
10
11
12
# yum -y install mysql-community-server
# systemctl start mysqld
# systemctl enable mysqld
# mysql
mysql>quit

이렇게 mysql까지 들어가면 프롬프트가 mysql>로 바뀌면 설치가 완료된 것입니다.

quit 명령으로 mysql에서 빠져 나옵니다.

 

 

 

 

 

 

 

 

 

 

 

1
# reboot

reboot 명령으로 재시작합니다.

1
# mysql

재시작 후 mysql 이 정상 실행 되면 정상적으로 설치가 완료된것입니다.

이제 mysql에서 명령을 입력합니다.

1
mysql> status

 

 

 

 

 

 

 

 

 

 



mysql 설정값을 보면 characterset 값이 latin1 인것을 알수 있습니다.

따라서 mysql의 charaterset 을 utf8로 통일 시키겠습니다.

이 값들을 바꾸려면 my.cnf 파일을 편집해 줍니다.

my.cnf 파일은 /etc/ 안에 있습니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# vi /etc/my.cnf
[client]
default-character-set = utf8
[mysql]
default-character-set=utf8
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
collation-server=utf8_general_ci
init_connect=SET collation_connection = utf8_general_ci
init_connect=SET NAMES utf8
character-set-client-handshake = FALSE
skip-character-set-client-handshake
[mysqldump]
default-character-set=utf8

값들을 보시고 기존에 있는것은 놔두고 없는것은 추가시켜주면 됩니다.

저장 후 mysql을 재시작해 줍니다.

1
2
3
4
5
# systemctl restart mysqld
# mysql
mysql> status

mysql을 실행하고  status 명령을 주면 이제 charcterset이 utf8로 바뀐것을 보실수 있습니다.

 

 

 

 

 

 

 

 

 

 






이제 mysql의 1차 설정은 끝입니다.

2차 설정은 php와 phpmyadmin을 설치한 후에 시작합니다..

반응형
Comments