본문 바로가기
구 블로그 보관처

LINUX - APM - MySQL 설치

by 행복한 만수킴 2020. 5. 17.

 



  • ​MySQL 설치
    • yum을 통해 MySQL이 있는지 검색함
      yum --enablerepo=epel,rpmforge,remi list mysql mysql-server
      (enablerepo 옵션을 사용하지 않으면, 낮은 버전이 검색됨. 금일 기준으로 '5.1.73-3'으로 검색이 되고 있음)
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      [root@centos ~]# yum --enablerepo=epel,rpmforge,remi list mysql mysql-server
      Loaded plugins: fastestmirror
      Loading mirror speeds from cached hostfile
      Excluding mirror: data.nicehosting.co.kr
       * base: centos.mirror.cdnetworks.com
       * epel: mirror.premi.st
      Excluding mirror: data.nicehosting.co.kr
       * extras: centos.mirror.cdnetworks.com
       * remi: remi.kazukioishi.net
       * rpmforge: ftp.kddilabs.jp
       * updates: centosd6.centos.org
      Available Packages
      mysql.x86_64                                           5.5.37-1.el6.remi                                     remi
      mysql-server.x86_64                                 5.5.37-1.el6.remi                                     remi


    • yum을 통한 설치
      yum --enablerepo=epel,rpmforge,remi install mysql mysql-server
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      99
      100
      101
      102
      103
      104
      105
      [root@centos ~]# yum --enablerepo=epel,rpmforge,remi install mysql mysql-server
      Loaded plugins: fastestmirror
      Loading mirror speeds from cached hostfile
      Excluding mirror: data.nicehosting.co.kr
       * base: centos.mirror.cdnetworks.com
       * epel: mirror.premi.st
      Excluding mirror: data.nicehosting.co.kr
       * extras: centos.mirror.cdnetworks.com
       * remi: remi.kazukioishi.net
       * rpmforge: ftp.kddilabs.jp
       * updates: centosd6.centos.org
      Setting up Install Process
      Resolving Dependencies
      --> Running transaction check
      ---> Package mysql.x86_64 0:5.5.37-1.el6.remi will be installed
      --> Processing Dependency: real-mysql-libs(x86-64) = 5.5.37-1.el6.remi for package: mysql-5.5.37-1.el6.remi.x86_64
      ---> Package mysql-server.x86_64 0:5.5.37-1.el6.remi will be installed
      --> Processing Dependency: perl-DBI for package: mysql-server-5.5.37-1.el6.remi.x86_64
      --> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.5.37-1.el6.remi.x86_64
      --> Processing Dependency: perl(DBI) for package: mysql-server-5.5.37-1.el6.remi.x86_64
      --> Running transaction check
      ---> Package mysql-libs.x86_64 0:5.1.73-3.el6_5 will be updated
      --> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-6.el6_5.x86_64
      --> Processing Dependency: libmysqlclient.so.16()(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
      --> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-6.el6_5.x86_64
      --> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
      ---> Package mysql-libs.x86_64 0:5.5.37-1.el6.remi will be an update
      ---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
      ---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
      --> Running transaction check
      ---> Package compat-mysql51.x86_64 0:5.1.54-1.el6.remi will be installed
      --> Finished Dependency Resolution
       
      Dependencies Resolved
       
      =================================================================================================================
       Package                       Arch                  Version                           Repository           Size
      =================================================================================================================
      Installing:
       mysql                         x86_64                5.5.37-1.el6.remi                 remi                5.8 M
       mysql-server                  x86_64                5.5.37-1.el6.remi                 remi                 10 M
      Installing for dependencies:
       compat-mysql51                x86_64                5.1.54-1.el6.remi                 remi                1.4 M
       perl-DBD-MySQL                x86_64                4.013-3.el6                       base                134 k
       perl-DBI                      x86_64                1.609-4.el6                       base                705 k
      Updating for dependencies:
       mysql-libs                    x86_64                5.5.37-1.el6.remi                 remi                776 k
       
      Transaction Summary
      =================================================================================================================
      Install       5 Package(s)
      Upgrade       1 Package(s)
       
      Total download size: 19 M
      Is this ok [y/N]: y
      Downloading Packages:
      (1/6): compat-mysql51-5.1.54-1.el6.remi.x86_64.rpm                                        | 1.4 MB     00:00     
      (2/6): mysql-5.5.37-1.el6.remi.x86_64.rpm                                                 | 5.8 MB     00:01     
      (3/6): mysql-libs-5.5.37-1.el6.remi.x86_64.rpm                                            | 776 kB     00:00     
      (4/6): mysql-server-5.5.37-1.el6.remi.x86_64.rpm                                          |  10 MB     00:02     
      (5/6): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                              | 134 kB     00:00     
      (6/6): perl-DBI-1.609-4.el6.x86_64.rpm                                                    | 705 kB     00:00     
      -----------------------------------------------------------------------------------------------------------------
      Total                                                                            3.8 MB/s |  19 MB     00:04     
      경고: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
      Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
      Importing GPG key 0x00F97F56:
       Userid : Remi Collet <RPMS@FamilleCollet.com>
       Package: remi-release-6.5-1.el6.remi.noarch (@/remi-release-6)
       From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
      Is this ok [y/N]: y
      Running rpm_check_debug
      Running Transaction Test
      Transaction Test Succeeded
      Running Transaction
        Installing : perl-DBI-1.609-4.el6.x86_64                                                                   1/7 
        Updating   : mysql-libs-5.5.37-1.el6.remi.x86_64                                                           2/7 
       
      WARNING : This MySQL RPM is not an official Fedora / Red Hat build and it
      overrides the official one. Do not file bugs on Fedora Project nor Red Hat.
      Use dedicated forums http://forums.famillecollet.com/
       
        Installing : mysql-5.5.37-1.el6.remi.x86_64                                                                3/7 
        Installing : compat-mysql51-5.1.54-1.el6.remi.x86_64                                                       4/7 
        Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                                             5/7 
        Installing : mysql-server-5.5.37-1.el6.remi.x86_64                                                         6/7 
        Cleanup    : mysql-libs-5.1.73-3.el6_5.x86_64                                                              7/7 
        Verifying  : mysql-libs-5.5.37-1.el6.remi.x86_64                                                           1/7 
        Verifying  : compat-mysql51-5.1.54-1.el6.remi.x86_64                                                       2/7 
        Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                             3/7 
        Verifying  : mysql-server-5.5.37-1.el6.remi.x86_64                                                         4/7 
        Verifying  : perl-DBI-1.609-4.el6.x86_64                                                                   5/7 
        Verifying  : mysql-5.5.37-1.el6.remi.x86_64                                                                6/7 
        Verifying  : mysql-libs-5.1.73-3.el6_5.x86_64                                                              7/7 
       
      Installed:
        mysql.x86_64 0:5.5.37-1.el6.remi                    mysql-server.x86_64 0:5.5.37-1.el6.remi                   
       
      Dependency Installed:
        compat-mysql51.x86_64 0:5.1.54-1.el6.remi  perl-DBD-MySQL.x86_64 0:4.013-3.el6  perl-DBI.x86_64 0:1.609-4.el6 
       
      Dependency Updated:
        mysql-libs.x86_64 0:5.5.37-1.el6.remi                                                                          
       
      Complete!


    • MySQL 서버의 시작과 종료
      1
      2
      /etc/init.d/mysqld start   <-- MySQL 시작
      /etc/init.d/mysqld stop   <-- MySQL 종료


    • MySQL 서버의 관리자(root) 암호 설정
      아래 1번이나 2번의 방법으로 설정이 가능하다고 한다. (여기서는 1번으로 설정했고, 2번은 참고용으로 기록함)
      1. /usr/bin/mysqladmin -u root password 'p@ssw0rd'
      1
      2
      [root@centos ~]# /usr/bin/mysqladmin -u root password '암호'
      [root@centos ~]# 


      2. /usr/bin/mysql_secure_installation

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      [root@db2 ~]# /usr/bin/mysql_secure_installation
       
       
       
       
      NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
            SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
       
       
      In order to log into MySQL to secure it, we'll need the current
      password for the root user.  If you've just installed MySQL, and
      you haven't set the root password yet, the password will be blank,
      so you should just press enter here.
       
      Enter current password for root (enter for none):
      OK, successfully used password, moving on...
       
      Setting the root password ensures that nobody can log into the MySQL
      root user without the proper authorisation.
       
      You already have a root password set, so you can safely answer 'n'.
       
      Change the root password? [Y/n] n
       ... 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? [Y/n] 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? [Y/n] 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? [Y/n] 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? [Y/n] y
       ... Success!
       
      Cleaning up...
       
       
       
      All done!  If you've completed all of the above steps, your MySQL
      installation should now be secure.
       
      Thanks for using MySQL!


       

    • Database 생성 및 사용자 생성
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      [root@centos ~]# mysql -u root -p
      Enter password: 
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 6
      Server version: 5.5.37 MySQL Community Server (GPL) by Remi
       
      Copyright (c) 2000, 2014, 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.
       
      Typ'help;' or '\h' for help. Type '\c' to clear the current input statement.
                  
      mysql> CREATE USER tank@localhost IDENTIFIEBY "암호";   <--  새로운 사용자 생성 
      Query OK, 0 rows affected (0.00 sec)
       
      mysql> CREATE DATABASE tank_home;                            <-- 새로운 데이터베이스 생성
      Query OK, 1 row affected (0.00 sec)
       
      mysql> GRANT ALL ON tank_home TO tank@localhost;   <-- 필요한 권한 설정
      ERROR 1046 (3D000): No database selected
      mysql> GRANT ALL ON tank_home.* TO tank@localhost;
      Query OK, 0 rows affected (0.00 sec)
       
      mysql> FLUSH PRIVILEGES;                                                   <-- 권한 설정 적용
      Query OK, 0 rows affected (0.00 sec)
       
      mysql> quit;
      Bye


      새로 생성한 유저가 새로운 DB로 접속이 되는지 확인
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      [tank@centos ~]$ mysql -u tank -p
      Enter password: 
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 10
      Server version: 5.5.37 MySQL Community Server (GPL) by Remi
       
      Copyright (c) 2000, 2014, 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 |
      | tank_home          |
      | test               |
      +--------------------+
      3 rows in set (0.00 sec)


    • 불필요한 test 데이터베이스 삭제
      1
      2
      mysql> DROP DATABASE test;
      Query OK, 0 rows affected (0.05 sec)


    • MySQL 설치 중 발생하는 문제 해결 참조 URL





 

댓글0