준비물
mysql 설치 rpm 파일
Centos7버전 OS
유저 생성
useradd mysql passwd mysql mysql |
설치방법
mysql 설치 다운로드 링크
https://www.mysql.com/products/community/
Download MySQL Community Edition 클릭
Yum Repository 클릭
OS 버전에 맞는 rpm Download 선택
다운받은 rpm을 설치된 리눅스로 옮기기
MySQL 설치 레포지토리 설치하기
rpm -ivh mysql80-community-release-el7-6.noarch.rpm |
MySQL 레포지토리 목록 확인
yum repolist enabled | grep "mysql.*" |
yum 레포지토리 확인(centos 7.4 설치 후 default 설정된 repository)
cd /etc/yum.repos.d ls -l |
MySQL 설치
yum -y install mysql-server |
GPG key retrieval failed: [Errno 14] curl#37 - "Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022" 에러 발생하여 정상 다운되지 않은 경우, 아래 명령어 수행 및 다운로드 재시도
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 yum -y install mysql-server |
설치 완료 확인
mysql -V |
MySQL 서버 자동 시작 && 서버 시작 && 서버 상태 조회
systemctl enable mysqld && systemctl start mysqld && systemctl status mysqld |
MySQL 8 버전은 서버 설치 과정에서 임시 비밀번호가 생성되며, 이 비밀번호로 접속이 가능
grep 'temporary password' /var/log/mysqld.log |
MySQL 접속 및 비밀번호 입력
mysql -u root -p BQ;e2:?uiKxt |
데이터 베이스 조회 시 에러 발생, ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
root 비밀번호 변경 필요, 비밀번호 조건이 까다롭기 때문에 단순하게 변경 시 변경 안됨
show databases; ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysql'; ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mycentos74!@'; |
현재 설정 되어 있는 profile 확인
show variables like 'validate_password%'; |
설정된 profile을 변경 후 비밀번호 변경
SET GLOBAL validate_password.check_user_name=OFF; SET GLOBAL validate_password.policy=LOW; SET GLOBAL validate_password.length=0; show variables like 'validate_password%'; ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysql'; |
해당 설정은 DB가 재기동 되면 초기화 되는 단점 존재
systemctl stop mysqld && systemctl start mysqld mysql -u root -p mysql show variables like 'validate_password%'; |
설정 파일 맨 아래에 값 추가
vi /etc/my.cnf ##### Password Policy ##### validate_password.policy=LOW validate_password.length=0 |
DB 재기동 후 접속하여 확인
systemctl stop mysqld && systemctl start mysqld mysql -u root -p show variables like 'validate_password%'; |
쉽게 변경되는 것 확인 가능
ALTER USER 'root'@'localhost' IDENTIFIED BY 'test'; |
'데이터베이스 > mysql' 카테고리의 다른 글
[mysql8.0.29]Centos7.4 mysql 8 mha0.57 설정 (0) | 2022.07.18 |
---|---|
[mysql8.0.29]Centos7.4 mysql 8 replication 설정 (0) | 2022.07.14 |
[mysql8.0.29]Centos7.4 mysql 8 binary 설치 (0) | 2022.06.13 |