728x90
반응형

CentOS 7 Minimal 64Bit + MySQL Community linux generic 64bit

위와 같이 설치 하면 기본적으로 엔진은 /usr/local/mysql 되어야 해서 소프트 링크를 생성해 준다

추후 엔진 업그레이드 시에 다른 엔진을 압축 후에 /usr/local/mysql 소프트 링크만 바꾸면 쉽게 업그레이드 된다.

 

0. 사전 준비

1 . 설치 파일 다운로드

   


 

2. 필요한 패키지 설치

CentOS 기본 설치 라서 네트워크 툴만 간단하게 설치

 

[root@localhost ~]# yum install net-tools

 

 

1. 엔진 파일 압축해제 소프트 링크 생성

 

[root@localhost ~]# ls

anaconda-ks.cfg  mysql-5.7.17-linux-glibc2.5-x86_64.tar

[root@localhost ~]# tar xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar

mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

mysql-test-5.7.17-linux-glibc2.5-x86_64.tar.gz

[root@localhost ~]# ls

anaconda-ks.cfg  mysql-5.7.17-linux-glibc2.5-x86_64.tar 

mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz  mysql-test-5.7.17-linux-glibc2.5-x86_64.tar.gz

 

[root@localhost ~]# tar xvfz mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

[root@localhost ~]# ls

anaconda-ks.cfg                     mysql-5.7.17-linux-glibc2.5-x86_64.tar     mysql-test-5.7.17-linux-glibc2.5-x86_64.tar.gz

mysql-5.7.17-linux-glibc2.5-x86_64  mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

 

[root@localhost ~]# cd mysql-5.7.17-linux-glibc2.5-x86_64

[root@localhost mysql-5.7.17-linux-glibc2.5-x86_64]# ls

bin  COPYING  docs  include  lib  man  README  share  support-files

[root@localhost mysql-5.7.17-linux-glibc2.5-x86_64]# pwd

/root/mysql-5.7.17-linux-glibc2.5-x86_64

 

[root@localhost mysql-5.7.17-linux-glibc2.5-x86_64]# ln -s /root/mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql

 

 

2. 그룹/유저/설정파일 수정

 

[root@localhost mysql-5.7.17-linux-glibc2.5-x86_64]# groupadd mysql

[root@localhost mysql-5.7.17-linux-glibc2.5-x86_64]# useradd -r -g mysql mysql

[root@localhost mysql-5.7.17-linux-glibc2.5-x86_64]# mkdir /data

[root@localhost mysql-5.7.17-linux-glibc2.5-x86_64]# chown -R mysql:mysql /data

 

[mysql]

socket=/data/mysql.sock

port=3306

 

[mysqld]

basedir=/usr/local/mysql

datadir=/data

socket=/data/mysql.sock

port=3306

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

symbolic-links=0

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions in http://fedoraproject.org/wiki/Systemd

 

[mysqld_safe]

log-error=/data/error.log

pid-file=/data/mysql.pid

 

#

# include all files from the config directory

#

!includedir /etc/my.cnf.d

 

3. DB 설치/root 패스워드 변경

 

[root@localhost bin]# /usr/local/mysql/bin/mysql_install_db --defaults-file=/etc/my.cnf --datadir=/data --user=mysql

2017-03-20 01:55:53 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize

2017-03-20 01:55:57 [ERROR]   The bootstrap log isn't empty:

2017-03-20 01:55:57 [ERROR]   2017-03-20T05:55:53.862681Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead

2017-03-20T05:55:53.863124Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)

2017-03-20T05:55:53.863129Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

2017-03-20T05:55:53.874240Z 0 [ERROR] Can't read from messagefile '/usr/share/mysql/english/errmsg.sys'

 

[root@localhost bin]# ps -ef | grep mysqld

root      2431  2253  0 01:56 pts/0    00:00:00 grep --color=auto mysqld

 

[root@localhost bin]# ls /data

auto.cnf    ca.pem      client-cert.pem  client-req.pem  ibdata1      ib_logfile1  performance_schema  server-key.pem  sys

ca-key.pem  ca-req.pem  client-key.pem   ib_buffer_pool  ib_logfile0  mysql        server-cert.pem     server-req.pem

 

 

[root@localhost ~]# cp /usr/local/mysql/bin/support-files/mysql.server /etc/init.d/mysqld

[root@localhost ~]# vi /etc/init.d/mysqld

basedir=/usr/local/mysql

datadir=/data

 

[root@localhost ~]# /etc/init.d/mysqld start

Starting MySQL. SUCCESS!

[root@localhost ~]# ps -ef | grep mysqld

root     10788     1  0 03:04 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data --pid-file=/data/localhost.localdomain.pid

mysql    10972 10788  3 03:04 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/error.log --pid-file=/data/localhost.localdomain.pid --socket=/data/mysql.sock --port=3306

root     11003  2253  0 03:04 pts/0    00:00:00 grep --color=auto mysqld

 

[root@localhost bin]# /usr/local/mysql/bin/mysql_secure_installation

 

Securing the MySQL server deployment.

 

Connecting to MySQL server using password in '/root/.mysql_secret'

 

VALIDATE PASSWORD PLUGIN can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD plugin?

 

Press y|Y for Yes, any other key for No: n

Using existing password for root.

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

 

New password:

 

Re-enter new password:

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) : n

 

 ... skipping.

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@localhost bin]# /usr/local/mysql/bin/mysql -uroot -pTkdldnjfem

mysql: [Warning] Using a password on the command line interface can be insecure.

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

Your MySQL connection id is 6

Server version: 5.7.17

 

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 ;

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

mysql> alter user 'root'@'localhost' identified by 'Tkdldnjfem' ;

Query OK, 0 rows affected (0.00 sec)

 

mysql> flush privileges ;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show databases ;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

| sys                |

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

4 rows in set (0.00 sec)

 

mysql> exit

Bye

 

4. 기동/중지

 

[root@localhost ~]# /etc/init.d/mysqld start

Starting MySQL. SUCCESS!

[root@localhost ~]# ps -ef | grep mysqld

root     10788     1  0 03:04 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data --pid-file=/data/localhost.localdomain.pid

mysql    10972 10788  3 03:04 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/error.log --pid-file=/data/localhost.localdomain.pid --socket=/data/mysql.sock --port=3306

root     11003  2253  0 03:04 pts/0    00:00:00 grep --color=auto mysqld

[root@localhost ~]# /etc/init.d/mysqld stop

Shutting down MySQL.. SUCCESS!

[root@localhost ~]# ps -ef | grep mysql

root     11032  2253  0 03:10 pts/0    00:00:00 grep --color=auto mysql

 

반응형

+ Recent posts