728x90
반응형

1. 엔진 설치

 

root@CyBill-MysqlDev:/home/c0075># useradd mysql

root@CyBill-MysqlDev:/># mkdir /data

root@CyBill-MysqlDev:/home/c0075># tar -xvf mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar

root@CyBill-MysqlDev:/home/c0075># ls

mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar        mysql-community-common-5.7.17-1.el6.x86_64.rpm  mysql-community-embedded-5.7.17-1.el6.x86_64.rpm        mysql-community-libs-5.7.17-1.el6.x86_64.rpm         mysql-community-server-5.7.17-1.el6.x86_64.rpm

mysql-community-client-5.7.17-1.el6.x86_64.rpm  mysql-community-devel-5.7.17-1.el6.x86_64.rpm   mysql-community-embedded-devel-5.7.17-1.el6.x86_64.rpm  mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm  mysql-community-test-5.7.17-1.el6.x86_64.rpm

root@CyBill-MysqlDev:/home/c0075># yum install mysql-community-{server,client,common,libs}-* mysql-5.*

Loaded plugins: fastestmirror, security

Setting up Install Process

Examining mysql-community-server-5.7.17-1.el6.x86_64.rpm: mysql-community-server-5.7.17-1.el6.x86_64

Marking mysql-community-server-5.7.17-1.el6.x86_64.rpm to be installed

Loading mirror speeds from cached hostfile

base                                                                                                                                                                                                                                                   | 1.2 kB     00:00    

others                                                                                                                                                                                                                                                 | 2.9 kB     00:00    

update                                                                                                                                                                                                                                                 | 3.0 kB     00:00    

update/primary_db                                                                                                                                                                                                                                      |  15 MB     00:00    

Examining mysql-community-client-5.7.17-1.el6.x86_64.rpm: mysql-community-client-5.7.17-1.el6.x86_64

Marking mysql-community-client-5.7.17-1.el6.x86_64.rpm to be installed

Examining mysql-community-common-5.7.17-1.el6.x86_64.rpm: mysql-community-common-5.7.17-1.el6.x86_64

Marking mysql-community-common-5.7.17-1.el6.x86_64.rpm to be installed

Examining mysql-community-libs-5.7.17-1.el6.x86_64.rpm: mysql-community-libs-5.7.17-1.el6.x86_64

Marking mysql-community-libs-5.7.17-1.el6.x86_64.rpm to be installed

Examining mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm: mysql-community-libs-compat-5.7.17-1.el6.x86_64

Marking mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm to be installed

No package mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar available.

Resolving Dependencies

--> Running transaction check

---> Package mysql-community-client.x86_64 0:5.7.17-1.el6 will be installed

---> Package mysql-community-common.x86_64 0:5.7.17-1.el6 will be installed

---> Package mysql-community-libs.x86_64 0:5.7.17-1.el6 will be obsoleting

---> Package mysql-community-libs-compat.x86_64 0:5.7.17-1.el6 will be obsoleting

---> Package mysql-community-server.x86_64 0:5.7.17-1.el6 will be installed

---> Package mysql-libs.x86_64 0:5.1.73-3.el6_5 will be obsoleted

--> Finished Dependency Resolution

Dependencies Resolved

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

 Package                                                              Arch                                            Version                                                 Repository                                                                                 Size

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

Installing:

 mysql-community-client                                               x86_64                                          5.7.17-1.el6                                            /mysql-community-client-5.7.17-1.el6.x86_64                                                99 M

 mysql-community-common                                               x86_64                                          5.7.17-1.el6                                            /mysql-community-common-5.7.17-1.el6.x86_64                                               2.5 M

 mysql-community-libs                                                 x86_64                                          5.7.17-1.el6                                            /mysql-community-libs-5.7.17-1.el6.x86_64                                                 8.9 M

     replacing  mysql-libs.x86_64 5.1.73-3.el6_5

 mysql-community-libs-compat                                          x86_64                                          5.7.17-1.el6                                            /mysql-community-libs-compat-5.7.17-1.el6.x86_64                                          5.4 M

     replacing  mysql-libs.x86_64 5.1.73-3.el6_5

 mysql-community-server                                               x86_64                                          5.7.17-1.el6                                            /mysql-community-server-5.7.17-1.el6.x86_64                                               768 M

Transaction Summary

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

Install       5 Package(s)

Total size: 884 M

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Warning: RPMDB altered outside of yum.

** Found 22 pre-existing rpmdb problem(s), 'yum check' output follows:

ipa-client-3.0.0-42.el6.centos.x86_64 has missing requires of sssd >= ('0', '1.11.6', None)

ipa-client-3.0.0-42.el6.centos.x86_64 has missing requires of libsss_autofs

sssd-ad-1.11.6-30.el6.x86_64 has missing requires of libsss_ldap_common.so()(64bit)

sssd-ad-1.11.6-30.el6.x86_64 has missing requires of sssd-common = ('0', '1.11.6', '30.el6')

sssd-common-pac-1.11.6-30.el6.x86_64 has missing requires of libsss_child.so()(64bit)

sssd-common-pac-1.11.6-30.el6.x86_64 has missing requires of libsss_crypt.so()(64bit)

sssd-common-pac-1.11.6-30.el6.x86_64 has missing requires of libsss_debug.so()(64bit)

sssd-common-pac-1.11.6-30.el6.x86_64 has missing requires of libsss_util.so()(64bit)

sssd-common-pac-1.11.6-30.el6.x86_64 has missing requires of sssd-common = ('0', '1.11.6', '30.el6')

sssd-ipa-1.11.6-30.el6.x86_64 has missing requires of libsss_ldap_common.so()(64bit)

sssd-ipa-1.11.6-30.el6.x86_64 has missing requires of sssd-common = ('0', '1.11.6', '30.el6')

sssd-krb5-1.11.6-30.el6.x86_64 has missing requires of sssd-common = ('0', '1.11.6', '30.el6')

sssd-krb5-common-1.11.6-30.el6.x86_64 has missing requires of libsss_child.so()(64bit)

sssd-krb5-common-1.11.6-30.el6.x86_64 has missing requires of libsss_debug.so()(64bit)

sssd-krb5-common-1.11.6-30.el6.x86_64 has missing requires of sssd-common = ('0', '1.11.6', '30.el6')

sssd-ldap-1.11.6-30.el6.x86_64 has missing requires of libsss_ldap_common.so()(64bit)

sssd-ldap-1.11.6-30.el6.x86_64 has missing requires of sssd-common = ('0', '1.11.6', '30.el6')

sssd-proxy-1.11.6-30.el6.x86_64 has missing requires of libsss_child.so()(64bit)

sssd-proxy-1.11.6-30.el6.x86_64 has missing requires of libsss_crypt.so()(64bit)

sssd-proxy-1.11.6-30.el6.x86_64 has missing requires of libsss_debug.so()(64bit)

sssd-proxy-1.11.6-30.el6.x86_64 has missing requires of libsss_util.so()(64bit)

sssd-proxy-1.11.6-30.el6.x86_64 has missing requires of sssd-common = ('0', '1.11.6', '30.el6')

  Installing : mysql-community-common-5.7.17-1.el6.x86_64                                                                                                                                                                                                                 1/6

  Installing : mysql-community-libs-5.7.17-1.el6.x86_64                                                                                                                                                                                                                   2/6

  Installing : mysql-community-client-5.7.17-1.el6.x86_64                                                                                                                                                                                                                 3/6

  Installing : mysql-community-server-5.7.17-1.el6.x86_64                                                                                                                                                                                                                 4/6

  Installing : mysql-community-libs-compat-5.7.17-1.el6.x86_64                                                                                                                                                                                                            5/6

  Erasing    : mysql-libs-5.1.73-3.el6_5.x86_64                                                                                                                                                                                                                           6/6

  Verifying  : mysql-community-server-5.7.17-1.el6.x86_64                                                                                                                                                                                                                 1/6

  Verifying  : mysql-community-libs-compat-5.7.17-1.el6.x86_64                                                                                                                                                                                                            2/6

  Verifying  : mysql-community-client-5.7.17-1.el6.x86_64                                                                                                                                                                                                                 3/6

  Verifying  : mysql-community-common-5.7.17-1.el6.x86_64                                                                                                                                                                                                                 4/6

  Verifying  : mysql-community-libs-5.7.17-1.el6.x86_64                                                                                                                                                                                                                   5/6

  Verifying  : mysql-libs-5.1.73-3.el6_5.x86_64                                                                                                                                                                                                                           6/6

Installed:

  mysql-community-client.x86_64 0:5.7.17-1.el6         mysql-community-common.x86_64 0:5.7.17-1.el6         mysql-community-libs.x86_64 0:5.7.17-1.el6         mysql-community-libs-compat.x86_64 0:5.7.17-1.el6         mysql-community-server.x86_64 0:5.7.17-1.el6       

Replaced:

  mysql-libs.x86_64 0:5.1.73-3.el6_5                                                                                                                                                                                                                                         

Complete!

root@CyBill-MysqlDev:/home/c0075># ls

mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar        mysql-community-common-5.7.17-1.el6.x86_64.rpm  mysql-community-embedded-5.7.17-1.el6.x86_64.rpm        mysql-community-libs-5.7.17-1.el6.x86_64.rpm         mysql-community-server-5.7.17-1.el6.x86_64.rpm

mysql-community-client-5.7.17-1.el6.x86_64.rpm  mysql-community-devel-5.7.17-1.el6.x86_64.rpm   mysql-community-embedded-devel-5.7.17-1.el6.x86_64.rpm  mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm  mysql-community-test-5.7.17-1.el6.x86_64.rpm

root@CyBill-MysqlDev:/home/c0075># ps -ef | grep mysqld

root     41099 39626  0 10:49 pts/0    00:00:00 grep --color=auto mysqld

 

root@CyBill-MysqlDev:/home/c0075># cat /etc/passwd

mysql:x:10084:10084::/home/mysql:/bin/bash

 

root@CyBill-MysqlDev:/home/c0075># cat /etc/group

mysql:x:10084:

 

 

설치 되면 자동으로 다음의 디렉터리에 설치 진행 .

 

Files or Resources

Location

Client programs and scripts

/usr/bin

mysqld server

/usr/sbin

Configuration file

/etc/my.cnf

Data directory

/var/lib/mysql

Error log file

For RHEL, Oracle Linux, CentOS or Fedora platforms: /var/log/mysqld.log

For SLES: /var/log/mysql/mysqld.log

Value of secure_file_priv

/var/lib/mysql-files

System V init script

For RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqld

For SLES: /etc/init.d/mysql

Systemd service

For RHEL, Oracle Linux, CentOS or Fedora platforms: mysqld

For SLES: mysql

Pid file

/var/run/mysql/mysqld.pid

Socket

/var/lib/mysql/mysql.sock

Keyring directory

/var/lib/mysql-keyring

Unix manual pages

/usr/share/man

Include (header) files

/usr/include/mysql

Libraries

/usr/lib/mysql

Miscellaneous support files (for example, error messages, and character set files)

/usr/share/mysql

 

 

2. DB 생성

위와 같이 설치 디렉터리에 설치가 진행이 되었어도 /var/lib/mysql 파일 밑에는 아무것도 존재 하지 않는다.

엔진만 설치 되었고, 기본 데이터베이스들은 설치 되지 않음.

 

최초 mysql 기동 시키면 DB 설치 .

 

root@CyBill-MysqlDev:/data># service mysqld start

MySQL µ¥LŸº£L½º Ċ± :                                     [  OK  ]

Installing validate password plugin:                       [  OK  ]

mysqld (;)¸¦ ½Ā٠:                                          [  OK  ]

root@CyBill-MysqlDev:/data># ls

root@CyBill-MysqlDev:/data># ps -ef | grep mysqld

root     43188     1  0 11:29 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql

mysql    43385 43188  1 11:29 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock

root     43430 39626  0 11:29 pts/0    00:00:00 grep --color=auto mysqld

root@CyBill-MysqlDev:/data># cd /var/lib/mysql

root@CyBill-MysqlDev:/var/lib/mysql># ls

auto.cnf  ca-key.pem  ca.pem  client-cert.pem  client-key.pem  ib_buffer_pool  ib_logfile0  ib_logfile1  ibdata1  ibtmp1  mysql  mysql.sock  mysql.sock.lock  mysqld_safe.pid  performance_schema  private_key.pem  public_key.pem  server-cert.pem  server-key.pem  sys

root@CyBill-MysqlDev:/var/lib/mysql># cat /var/log/mysqld.log | grep temporary

2017-01-24T02:29:06.537569Z 1 [Note] A temporary password is generated for root@localhost: yWVtU7Exfn#<

2017-01-24T02:29:16.209967Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables

2017-01-24T02:29:18.267807Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"

2017-01-24T02:29:19.641895Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables

 

패스워드 변경

 

root@CyBill-MysqlDev:/var/lib/mysql># mysql -uroot -p

Enter password: yWVtU7Exfn#<

 

mysql> show databases ;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> alter user 'root'@'localhost' IDENTIFIED BY 'Tk2dnjfem!' ;

Query OK, 0 rows affected (0.00 sec)

 

mysql> flush privileges ;

Query OK, 0 rows affected (0.00 sec)

 

 

3. datadir 변경

 

기본 데이터 디렉터리를  var/lib/mysql --> /data 변경해 준다.

 

다음에서 보면 기본 datadir 위치를 있음.

 

root@CyBill-MysqlDev:/data># ps -ef | grep mysqld

root     43188     1  0 11:29 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql

mysql    43385 43188  1 11:29 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock

root     43430 39626  0 11:29 pts/0    00:00:00 grep --color=auto mysqld

 

root@CyBill-MysqlDev:/var/lib/mysql># service mysqld stop

mysqld ¸¦ d¶ :                                             [  OK  ]

 

데이터 디렉터리를 var/lib/mysql --> /data 변경 하기 위함.

 

root@CyBill-MysqlDev:/root># cp -r /var/lib/mysql/* /data/.  mv 해도 되지만 나중에 사용할 일이 있을지 모르니 남겨둠

root@CyBill-MysqlDev:/root># chown -R mysql:mysql /data

 

 

/etc/my.cnf 파일의 내용을 변경 .

 

기본 /etc/my.cnf 파일 내용

 

root@CyBill-MysqlDev:/var/lib/mysql># cat /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

 

변경 /etc/my.cnf 파일의 내용

 

root@CyBill-MysqlDev:/># cat /etc/my.cnf

[client]

socket=/data/mysql.sock

 

[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

datadir=/data

socket=/data/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

log-error=/data/mysqld.log

pid-file=/data/mysqld.pid

 

정상 기동하는 확인

 

root@CyBill-MysqlDev:/># service mysqld start

Logging to '/data/mysqld.log'.

mysqld (;)¸¦ ½Ā٠:                                          [  OK  ]

root@CyBill-MysqlDev:/>#

root@CyBill-MysqlDev:/>#

root@CyBill-MysqlDev:/># ps -ef | grep mysqld

root     45420     1  0 12:02 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/data --socket=/data/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql

mysql    45615 45420  4 12:02 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/data --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/data/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/data/mysql.sock

root     45710 39626  0 12:02 pts/0    00:00:00 grep --color=auto mysqld

root@CyBill-MysqlDev:/># mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.7.17 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> show databases ;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.00 sec)

 

mysql> show global variables like 'data%' ;

+---------------+--------+

| Variable_name | Value  |

+---------------+--------+

| datadir       | /data/ |

+---------------+--------+

1 row in set (0.00 sec)

 

mysql> exit

 

위에 보면 pid 파일이 그대로 /var 밑에 존재 . my.cnf 파일에는 다른 위치로 되어 있으나 기동 시에  파라미터로 나열해서 나중의 파라미터 값이 적용 결과

이건 나중에 수정하는 것으로 하고 .. slow query 부분을 추가.

 

/etc/my.cnf 파일에 다음 내용 추가

#SlowQuery

slow_query_log=1

long_query_time=1

slow_query_log_file=/data/slow_query.log

 

root@CyBill-MysqlDev:/># service mysqld stop

mysqld ¸¦ d¶ :                                             [  OK  ]

root@CyBill-MysqlDev:/># service mysqld start

mysqld (;)¸¦ ½Ā٠:                                          [  OK  ]

 

 

 

4. Root 접속 권한 설정 일반 유저 생성

root 외부 접속 가능 여부 설정 일반 유저 설정

패스워드를 변경하기 전에 패스워드 정책에 따라서 패스워드 생성 시에 제약이 따른다.

validate_password_policy

LOW : 8자리 이상이면 가능

MEDIUM :  숫자,소문자,대문자,특수문자 모두 포함해야 .

 

root 원격 접속 유저 생성

mysql> create user 'root'@'%' identified by 'root1122' ;

mysql> grant all privileges on *.* to 'root'@'%' identified by 'root1122' with grant option ;

 

일반 유저 생성

mysql> create user 'cybill'@'%' identified by 'cybill1@' ;

mysql> grant all privileges on cybill.* to 'cybill'@'%' identified by 'cybill1@' with grant option ;

 

 

반응형

+ Recent posts