메뉴 건너뛰기

Korea Oracle User Group

DBMS

MySQL CentOS 6.7 에서 MySQL 5.7 설치

명품관 2016.09.09 09:47 조회 수 : 5685

CentOS 6.7 에서 MySQL 5.7 설치

 

1. MySQL Yum Repository 구성

 

1) MySQL 사이트에서 Yum Repository 사용한 설치를 위해 아래 이름의 파일을 다운 받는다. down

  mysql57-community-release-el6-8.noarch.rpm

 

2) 설치

[root@testora ~]# rpm -Uvh mysql57-community-release-el6-8.noarch.rpm 
경고: mysql57-community-release-el6-8.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
준비 중...               ########################################### [100%]
   1:mysql57-community-relea########################################### [100%]
[root@testora ~]# 

 

3) yum 명령어를 통해 패키지 목록을 확인하여 본다.

[root@testora ~]# yum search mysql-community
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.daumkakao.com
 * extras: ftp.daumkakao.com
 * updates: ftp.daumkakao.com
============================================================= 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-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.1.72 database client applications
mysql-community-libs-compat.x86_64 : Shared compat libraries for MySQL 5.1.72 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

  Name and summary matches only, use "search all" for everything.
[root@testora ~]# 

 

4) yum을 통해 MySQL과 의존성에 걸려 있는 모든 패키지를 설치한다.

[root@testora ~]# yum install mysql-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.daumkakao.com
 * extras: ftp.daumkakao.com
 * updates: ftp.daumkakao.com
Package mysql-server is obsoleted by mysql-community-server, trying to install mysql-community-server-5.7.15-1.el6.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.15-1.el6 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.15-1.el6 for package: mysql-community-server-5.7.15-1.el6.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.15-1.el6.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.15-1.el6 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.15-1.el6.x86_64
---> Package mysql-community-common.x86_64 0:5.7.15-1.el6 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.15-1.el6 will be obsoleting
---> Package mysql-libs.x86_64 0:5.1.73-5.el6_6 will be obsoleted
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-6.el6_7.1.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-6.el6_7.1.x86_64
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.15-1.el6 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================
 Package                                        Arch                      Version                            Repository                            Size
========================================================================================================================================================
Installing:
 mysql-community-libs                           x86_64                    5.7.15-1.el6                       mysql57-community                    2.1 M
     replacing  mysql-libs.x86_64 5.1.73-5.el6_6
 mysql-community-libs-compat                    x86_64                    5.7.15-1.el6                       mysql57-community                    1.6 M
     replacing  mysql-libs.x86_64 5.1.73-5.el6_6
 mysql-community-server                         x86_64                    5.7.15-1.el6                       mysql57-community                    144 M
Installing for dependencies:
 mysql-community-client                         x86_64                    5.7.15-1.el6                       mysql57-community                     23 M
 mysql-community-common                         x86_64                    5.7.15-1.el6                       mysql57-community                    327 k

Transaction Summary
========================================================================================================================================================
Install       5 Package(s)

Total download size: 170 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): mysql-community-client-5.7.15-1.el6.x86_64.rpm                                                                            |  23 MB     00:20     
(2/5): mysql-community-common-5.7.15-1.el6.x86_64.rpm                                                                            | 327 kB     00:00     
(3/5): mysql-community-libs-5.7.15-1.el6.x86_64.rpm                                                                              | 2.1 MB     00:03     
(4/5): mysql-community-libs-compat-5.7.15-1.el6.x86_64.rpm                                                                       | 1.6 MB     00:02     
http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/mysql-community-server-5.7.15-1.el6.x86_64.rpm: [Errno 14] PYCURL ERROR 56 - "Failure when receiving data from the peer"
Trying other mirror.


Error Downloading Packages:
  mysql-community-server-5.7.15-1.el6.x86_64: failure: mysql-community-server-5.7.15-1.el6.x86_64.rpm from mysql57-community: [Errno 256] No more mirrors to try.

[root@testora ~]# 

다운로드에 실패할 경우 다시 시도하게 되면 실패한 파일을 받으면서 이후 과정이 진행된다.

[root@testora ~]# yum install mysql-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.daumkakao.com
 * extras: ftp.daumkakao.com
 * updates: ftp.daumkakao.com
Package mysql-server is obsoleted by mysql-community-server, trying to install mysql-community-server-5.7.15-1.el6.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.15-1.el6 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.15-1.el6 for package: mysql-community-server-5.7.15-1.el6.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.15-1.el6.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.15-1.el6 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.15-1.el6.x86_64
---> Package mysql-community-common.x86_64 0:5.7.15-1.el6 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.15-1.el6 will be obsoleting
---> Package mysql-libs.x86_64 0:5.1.73-5.el6_6 will be obsoleted
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-6.el6_7.1.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-6.el6_7.1.x86_64
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.15-1.el6 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================
 Package                                        Arch                      Version                            Repository                            Size
========================================================================================================================================================
Installing:
 mysql-community-libs                           x86_64                    5.7.15-1.el6                       mysql57-community                    2.1 M
     replacing  mysql-libs.x86_64 5.1.73-5.el6_6
 mysql-community-libs-compat                    x86_64                    5.7.15-1.el6                       mysql57-community                    1.6 M
     replacing  mysql-libs.x86_64 5.1.73-5.el6_6
 mysql-community-server                         x86_64                    5.7.15-1.el6                       mysql57-community                    144 M
Installing for dependencies:
 mysql-community-client                         x86_64                    5.7.15-1.el6                       mysql57-community                     23 M
 mysql-community-common                         x86_64                    5.7.15-1.el6                       mysql57-community                    327 k

Transaction Summary
========================================================================================================================================================
Install       5 Package(s)

Total size: 170 M
Total download size: 144 M
Is this ok [y/N]: y
Downloading Packages:
mysql-community-server-5.7.15-1.el6.x86_64.rpm                                                                                   | 144 MB     00:40     
경고: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid : MySQL Release Engineering <mysql-build@oss.oracle.com>
 Package: mysql57-community-release-el6-8.noarch (installed)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : mysql-community-common-5.7.15-1.el6.x86_64                                                                                           1/6 
  Installing : mysql-community-libs-5.7.15-1.el6.x86_64                                                                                             2/6 
  Installing : mysql-community-client-5.7.15-1.el6.x86_64                                                                                           3/6 
  Installing : mysql-community-server-5.7.15-1.el6.x86_64                                                                                           4/6 
  Installing : mysql-community-libs-compat-5.7.15-1.el6.x86_64                                                                                      5/6 
  Erasing    : mysql-libs-5.1.73-5.el6_6.x86_64                                                                                                     6/6 
  Verifying  : mysql-community-common-5.7.15-1.el6.x86_64                                                                                           1/6 
  Verifying  : mysql-community-libs-5.7.15-1.el6.x86_64                                                                                             2/6 
  Verifying  : mysql-community-client-5.7.15-1.el6.x86_64                                                                                           3/6 
  Verifying  : mysql-community-server-5.7.15-1.el6.x86_64                                                                                           4/6 
  Verifying  : mysql-community-libs-compat-5.7.15-1.el6.x86_64                                                                                      5/6 
  Verifying  : mysql-libs-5.1.73-5.el6_6.x86_64                                                                                                     6/6 

Installed:
  mysql-community-libs.x86_64 0:5.7.15-1.el6     mysql-community-libs-compat.x86_64 0:5.7.15-1.el6     mysql-community-server.x86_64 0:5.7.15-1.el6    

Dependency Installed:
  mysql-community-client.x86_64 0:5.7.15-1.el6                               mysql-community-common.x86_64 0:5.7.15-1.el6                              

Replaced:
  mysql-libs.x86_64 0:5.1.73-5.el6_6                                                                                                                    

Complete!
[root@testora ~]# 

 

5) 서버 시작시 자동으로 사용하기 위해 아래 작업을 수행한다.

[root@testora etc]# chkconfig mysqld on
[root@testora etc]# service mysqld start
MySQL 데이타베이스 초기화 중:  [  OK  ]
Installing validate password plugin:  [  OK  ]
mysqld (을)를 시작 중:  [  OK  ]
[root@testora etc]# 

 

6) 설치 후 root 패스워드에 대해 접근 에러가 발생 해결

   해당 이슈에 대해서 인터넷 상에 많은 이야기가 존재한다.

   설치 후 해당 내용에 대해 세팅하는 과정을 거쳐야하는데 그 사항을 진행하지도 못하는 상황이 연출됨

   아래는 이에 대한 해결 내용임

[root@testora etc]# service mysqld stop
mysqld 를 정지 중:  [  OK  ]
[root@testora etc]# service mysqld start --skip-grant-tables
mysqld (을)를 시작 중:  [  OK  ]
[root@testora etc]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> update user set authentication_string=password('mysql') where user='root';
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
[root@testora etc]# service mysqld restart
mysqld 를 정지 중:  [  OK  ]
mysqld (을)를 시작 중:  [  OK  ]
[root@testora etc]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.15

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select 1;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> SET PASSWORD = PASSWORD('Mysql1234!@#$');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

mysql> show variables like 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password_check_user_name    | OFF    |
| validate_password_dictionary_file    |        |
| validate_password_length             | 8      |
| validate_password_mixed_case_count   | 1      |
| validate_password_number_count       | 1      |
| validate_password_policy             | MEDIUM |
| validate_password_special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.00 sec)

mysql> 

 

7) selinux를 Permissive 모드로 변경 데이터, 로그 및 temp 사용 공간에 대한 설정 수정

[root@testora /]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=permissive
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
~
~

[root@testora /]# mkdir -p /u01/mysql/data
[root@testora /]# mkdir -p /u01/mysql/log_bin
[root@testora /]# mkdir -p /u01/mysql/tmpdir
[root@testora /]# chmod -R 755 /u01

[root@testora /]# vi /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# 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

# Add Kwan
log_bin=/u01/mysql/log_bin/myDB
datadir=/u01/mysql/data
tmpdir=/u01/mysql/tmpdir
~
~
~
~
"/etc/my.cnf" 32L, 1054C written
[root@testora /]# service mysqld start
mysqld (을)를 시작 중:  [  OK  ]

 

8) 보안을 위한 설정체크를 위한 스크립트 수행

[root@testora /]# mysql_secure_installation 

Securing the MySQL server deployment.

Enter password for user root: 
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

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

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

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


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

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

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


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

 - Removing privileges on test database...
Success.

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

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

All done! 
[root@testora /]# 

 

9) database 생성

[root@testora /]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> 
mysql> 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> create database kwandatabase;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| kwandatabase       |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> 

 

 

Addition

mysql에 접속하기 위해서는 random password를 확인해야 한다.

random password 확인하는 방법은 MySQL 버전에 따라 조금씩 틀리다.


[root@MySQL ~]# grep 'temporary password' /var/log/mysqld.log
2015-12-26T09:32:43.121947Z 1 [Note] A temporary password is generated for root@localhost: YV)zw<xy:3be

 

[root@MySQL ~]#  mysql - u root -p
random으로 설정되어 있는 패스워드 입력

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '1q2W3e$r%T';
mysql> flush privileges;

 

* 5.7.10버전에서는 validate_password 플러그인이 디폴트로 설치된다.
이것은 패스워드 설정에 대한 정책을 적용하는 것이다.

적어도 하나의 대문자, 소문자. 숫자, 특수문자를 요구하며 8자 이상이 되어야 한다.

 

위로