참고 : https://www.howtoforge.com/tutorial/how-to-install-mysql-57-on-linux-centos-and-ubuntu/

Step 1 - Add New Repository
yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
(대상 버전은 https://dev.mysql.com/downloads/repo/yum/ 에서 최신버전 확인 가능)


Step 2 - Install MySQL 5.7
yum -y install mysql-community-server


Step 3 - Start MySQL and Enable Start at Boot Time
systemctl start mysqld
systemctl enable mysqld

#부팅시 자동으로 시작되도록 설정되어 있는지 확인
systemctl is-enabled mysqld

#3306포트로 실행되어 있는지 확인
netstat -plntu


Step 4 - Configure the MySQL Root Password
MySQL 5.7 is installed and started. As you can see, the MySQL root password for Ubuntu has been configured during the installation process, so we do not need to configure or reset the password on Ubuntu. But this is not the case on CentOS.
On CentOS 7, MySQL will generate a strong default password when MySQL is started the first time, the default password is shown in the mysqld.log file. You can use the grep command below for showing the default MySQL password.
grep 'temporary' /var/log/mysqld.log

Connect to the MySQL shell with the default password. (로그 파일에서 root 계정의 임시 비밀번호 확인 후 접속)
mysql -u root -p
TYPE DEFAULT PASSWORD


Now replace the default password with a new and strong password, with the MySQL query below.

ALTER USER 'root'@'localhost' IDENTIFIED BY '신규암호';
flush privileges;


#추가설정
mysql> status
characterset 값이 latin1 인것을 확인할 수 있는데, 이런 characterset 등  몇가지는 기본적으로 바꾸는게 좋다

설정 참고(inno db 튜닝 등도 하면 좋지만 이 글에서는 pass)
# vi /etc/my.cnf  후 아래 내용 참고하여 필요 부분 변경 후 -> systemctl restart mysqld -> mysql 접속해서 status로 확인하면 변경됨을 확인할 수 있음

[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

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[client]
default-character-set = utf8

[mysql]
default-character-set=utf8





Posted by 고잉고