db/mysql

centos7 mysql5.7

C/H 2017. 2. 24. 08:30

centos7 mysql5.7 Install

# 5.7 appnend repo
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm && yum localinstall mysql57-community-release-el7-7.noarch.rpm -y

yum repolist enabled | grep "mysql.*-community.*"
yum install mysql-server mysql-devel -y

systemctl status mysqld.service
mysql --version

systemctl enable mysqld.service
systemctl start mysqld.service
mysql -u root -p

# root password temporary set
mysql_secure_installation

# check temporary password
grep 'temporary password' /var/log/mysqld.log
2017-02-20T07:32:32.983446Z 1 [Note] A temporary password is generated for root@localhost: password

삭제 후 재 설치

# remove mysql, reinstall
systemctl stop mysqld.service
yum remove mysql* -y
mv /var/lib/mysql /var/lib/mysql_old_backup
rm -fvR /var/lib/mysql
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm && yum localinstall mysql57-community-release-el7-7.noarch.rpm -y
yum install mysql-server mysql-devel -y
systemctl start mysqld
mysql_secure_installation
grep 'temporary password' /var/log/mysqld.log

root password setting

mysql -u root -p mysql
# <= 5.7.7
update mysql.user set password=password('password') where user='root';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
# >= 5.7.8
update user set authentication_string=password('password') where user='root';
# Error
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
# root password setting
SET PASSWORD = PASSWORD('password');
SET PASSWORD = 'password';   # validate-password=off 설정 시
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
# 비밀번호 정책을 변경 하거나 정책에 맞는 비밀번호로 변경
# my.cnf 추가/수정
# 미 사용 : validate-password=off
# 정책 변경 : validate_password_policy=LOW|MEDIUM|STRONG
# validate_password_policy=LOW  8자 이상
# validate_password_policy=MEDIUM  8자이상,숫자,소문자,대문자,특수문자
# validate_password_policy=STRONG  8자이상,숫자,소문자,대문자,특수문자,사전단어 포함
# 에러가 발생하지 않는다면 아래 쿼리로 root 비밀번호를 업데이트 한다.

update user set authentication_string=password('password') where user='root';
select host, user, authentication_string from user;

none password root@localhost

vi /etc/mysql/my.cnf
# or other path my.cnf

[mysqld]
skip-grant-tables

sudo systemctl restart mysql
반응형