관리 메뉴

IT.FARMER

cent os 7 mysql 8 설치 본문

DataBase/mysql

cent os 7 mysql 8 설치

아이티.파머 2020. 9. 15. 13:14
반응형

1. Mysql 설치

1.1 다른 버전이 들어 있는지 확인 (기존 링크 체크 ) 불필요한 버전 삭제

mysql 확인후 아래 불필요한 버전 링크 삭제

# rpm -qa | grep mysql 확인후 아래 불필요한 버전 링크 삭제
rpm -qa | grep mysql 
rpm -e --nodeps mysql57-community-release-el7-7.noarch
rpm -e --nodeps mysql-libs-5.1.73-8.el6_8.x86_64
rpm -e --nodeps mysql-5.1.73-8.el6_8.x86_64
rpm -e --nodeps mysql-devel-5.1.73-8.el6_8.x86_64

 

1.2 OS 버전에 맞는 파일 다운로드

1.3 MySQL Yum 저장소 추가하기

  • sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm
  • yum repolist 로 추가된 저장소 목록 확인 (목록 1.5 체크)

1.4 저장소 업데이트

yum clean all

yum update

1.5 패키지 목록 확인 및 설치

1.5.1 yum search mysql-community 명령어로 전체 패키지 목록 확인

yum search mysql-community

========================================================================================================================

N/S Matched: mysql-community

========================================================================================================================
mysql-community-client.i686 : MySQL database client applications and tools
mysql-community-client.x86_64 : MySQL database client applications and tools
mysql-community-common.i686 : MySQL database common files for server and client libs
mysql-community-common.x86_64 : MySQL database common files for server and client libs
mysql-community-devel.i686 : Development header files and libraries for MySQL database client applications
mysql-community-devel.x86_64 : Development header files and libraries for MySQL database client applications
mysql-community-embedded.i686 : MySQL embedded library
mysql-community-embedded.x86_64 : MySQL embedded library
mysql-community-embedded-compat.i686 : MySQL embedded compat library
mysql-community-embedded-compat.x86_64 : MySQL embedded compat library
mysql-community-embedded-devel.i686 : Development header files and libraries for MySQL as an embeddable library
mysql-community-embedded-devel.x86_64 : Development header files and libraries for MySQL as an embeddable library
mysql-community-libs.i686 : Shared libraries for MySQL database client applications
mysql-community-libs.x86_64 : Shared libraries for MySQL database client applications
mysql-community-libs-compat.i686 : Shared compat libraries for MySQL 5.6.25 database client applications
mysql-community-libs-compat.x86_64 : Shared compat libraries for MySQL 5.6.25 database client applications
mysql-community-release.noarch : MySQL repository configuration for yum
mysql-community-server.x86_64 : A very fast and reliable SQL database server
mysql-community-test.x86_64 : Test suite for the MySQL database server
==================================================================================

이중에서 다음과 같은 패키지를 설치하면 된다.
mysql-community-server : 서버
mysql-community-client: 명령행 클라이언트
mysql-community-libs :
mysql-community-common :
mysql-community-server 는 나머지 3개 패키지에 의존성이 걸려 있으므로 다음 yum 명령어는 4 개의 패키지를 전부 설치한다.

 

이중에서 다음과 같은 패키지를 설치하면 된다. mysql-community-server : 서버 mysql-community-client: 명령행 클라이언트 mysql-community-libs : mysql-community-common : mysql-community-server 는 나머지 3개 패키지에 의존성이 걸려 있으므로 다음 yum 명령어는 4 개의 패키지를 전부 설치한다.

다음 명령을 통해 MySQL Yum 저장소가 성공적으로 추가되었는지 확인할 수 있습니다 :

yum repolist enabled | grep "mysql.-community."

mysql-connectors-community MySQL Connectors Community 74
mysql-tools-community MySQL Tools Community 74
mysql57-community MySQL 8.0 Community Server 307

1.6 설치

> yum install mysql-community-server

이렇게하면 MySQL 서버 ( mysql-community-server) 용 패키지가 설치되고 클라이언트 ( mysql-community-client) 용 패키지 , 클라이언트 및 서버 ( mysql-community-common) 용 공통 오류 메시지 및 문자 세트 및 공유 클라이언트 라이브러리 ( mysql-community-libs)가 포함 된 서버 실행에 필요 한 구성 요소 패키지가 설치됩니다. .

1.7 보안 및 권한 설정

mysql 5.7 버전 부터는 root로 바로 접속 할 수 없다. 임시비밀번호를 확인해서 접속하거나

**mysql_secure_installation (보안설정)**을 수행한다.

  • mysql -u root

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

1.7.1 설치시 임시 패스워드 확인

  • sudo cat /var/log/mysqld.log

2018-11-19T04:32:55.260934Z 1 [Note] A temporary password is generated for root@localhost: (guty4>f/84A

  • mysql_secure_installation

root 계정의 새로운 비밀번호 지정 비밀번호는 (대소문자숫자포함 강력하게해야한다.)

ated strength of the password: 100Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password:Sorry, you can't use an empty password here.

New password:

Re-enter new password:

Estimated strength of the password: 100Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : yBy default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : ySuccess.

Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : ySuccess.

By default, MySQL comes with a database named 'test' thatanyone can access. This is also intended only for testing,and should be removed before moving into a productionenvironment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : yDropping test database...Success.

- Removing privileges on test database...Success.

Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : ySuccess.

All done!

1.7.2 mysql 접속

  • mysql -u root -p {신규패스워드}

1.8 권한 설정

  • 원격지 사용자 정보 확인

SELECT Host,User,authentication_string FROM mysql.user;

1.8.1 데이터 베이스 생성 및 유저 생성

CREATE SCHEMA `test_db` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin ;
ALTER SCHEMA `test_db` DEFAULT COLLATE utf8mb4_bin ;

* test 계정
create user 'test_user'@'%' identified by 'test12!@';
grant all privileges on test_db.* to test_user@'%';
flush privileges;

* root 계정( 보안정책에 의해 root 계정은 특정 아이피대역 외 원격 접속 불가 )
grant all privileges on *.* to root@'xxx.xxx.xxx.*';
flush privileges

1.9. 환경 설정

외부 접속 및 기타 mysql 환경 설정

1.9.1 my.cnf 설정 변경

이모티콘 저장을 위함 utf8mb4

  • sudo vim /etc/my.cnf
[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
skip-character-set-client-handshake


# stored function 사용시 추가 
log_bin_trust_function_creators=1

 

1.9.2 LISTEN IP대역 변경

=> SKIP

  • 시스템 부팅시 자동 구동되도록 설정

sudo systemctl enable mysqld

sudo systemctl restart mysqld

참고

  • mysql 8 버전 접속 오류 (AllowPublicKeyRetrieval)

Caused by: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

8 버전 이상부터는 기본적으로 caching_sha2_password 인증 플러그인을 사용한다.

SSL 옵션이 비활성화 된경우에만 관련되며, useSSL을 false로 한경우 allowPublicKeyRetrieval=true 옵션으로 서버에서 공개키 생성을 하도록 설정을 추가한다.

반응형

'DataBase > mysql' 카테고리의 다른 글

mysql data backup (dump)  (0) 2022.05.11
mysql collate 변경 column , table  (0) 2020.11.30
Mysql 이모지(이모티콘) 4byte 적용  (0) 2019.05.08
mysql 사용자 추가 DB 권한부여  (0) 2018.09.18
JAVA Mysql 타입 매칭  (0) 2018.08.06