블로그 이미지
BJcomm
bjcomm

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

calendar

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
12-22 10:19

MYSQL 5.7 INSTALL ( mysql 5.7.9 )

2016. 2. 1. 13:58 | Posted by bjcomm

MYSQL 5.7 INSTALL ( mysql 5.7.9 )
O/S : CentOS 6.x (64bit)

1. mysql 5.7.9 버전을 설치하기 위해서는 boost 라이브러리가 필요하다  파일은 같은 디록토리 내에서 받고 압축을 풀고
mysql을 설치 진행하면 된다.

[root@localhost ~]# yum -y install gcc gcc-c++ ncurses ncurses-devel cmake

[root@localhost ~]# wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

[root@localhost ~]# tar xvfz boost_1_59_0.tar.gz 

[root@localhost ~]# wget mirror.koreaidc.com/mysql/mysql-5.7.9.tar.gz

[root@localhost ~]# tar xvfz mysql-5.7.9.tar.gz 

[root@localhost ~]# cd mysql-5.7.9

[root@localhost mysql-5.7.9]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DWITH_EXTRA_CHARSETS=all \
-DMYSQL_DATADIR=/free/mysql_data \
-DENABLED_LOCAL_INFILE=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=../boost_1_59_0 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DSYSCONFDIR=/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all

2.  make / make install 을 진행한다  ( make 작업시 cpu 코어갯수대로 진행을 할수 있게 옵션을 줘서 진행)

[root@localhost mysql-5.7.9]# make -j `grep processor /proc/cpuinfo | wc -l`

[root@localhost mysql-5.7.9]# make install

3.  mysql 사용자 추가 및 권한 설정 / 환경설정 파일 복사

[root@localhost mysql-5.7.9]# useradd -M mysql -u 27 >& /dev/null

[root@localhost mysql-5.7.9]# chown -R root:mysql /usr/local/mysql

[root@localhost mysql-5.7.9]# cd /usr/local/mysql

[root@localhost mysql]# chmod 700 support-files/mysql.server

[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql

[root@localhost mysql]# ln -s /etc/rc.d/init.d/mysql /etc/rc.d/rc3.d/S97mysql

[root@localhost mysql]# cp support-files/mysql.server /usr/bin/

4.   my.cnf 파일을 작성한다  ( default engine  myisam )   / 만약  innodb 를 하려면 5번 항목으로

[root@localhost mysql]# vi /etc/my.cnf



[client]
default-character-set = utf8
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8


[mysqld]
socket=/tmp/mysql.sock
datadir=/free/mysql_data
basedir = /usr/local/mysql
#user = mysql
#bind-address = 0.0.0.0
# 
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M

#dns query
skip-name-resolve

#connection
max_connections = 1000
max_connect_errors = 1000
wait_timeout= 60

#slow-queries
#slow_query_log = /free/mysql_data/slow-queries.log
#long_query_time = 3
#log-slow-queries = /free/mysql_data/mysql-slow-queries.log

##timestamp
explicit_defaults_for_timestamp

symbolic-links=0

### log
log-error=/free/mysql_data/mysqld.log
pid-file=/tmp/mysqld.pid

###chracter
character-set-client-handshake=FALSE
init_connect = SET collation_connection = utf8_general_ci
init_connect = SET NAMES utf8
character-set-server = utf8
collation-server = utf8_general_ci

symbolic-links=0

##Password Policy
#validate_password_policy=LOW
#validate_password_policy=MEDIUM


### MyISAM Spectific options
default-storage-engine = myisam
key_buffer_size = 32M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1


### INNODB Spectific options
#default-storage-engine = InnoDB
#skip-innodb
#innodb_additional_mem_pool_size = 16M
#innodb_buffer_pool_size = 1024MB
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_write_io_threads = 8
#innodb_read_io_threads = 8
#innodb_thread_concurrency = 16
#innodb_flush_log_at_trx_commit = 1
#innodb_log_buffer_size = 8M
#innodb_log_file_size = 128M
#innodb_log_files_in_group = 3
#innodb_max_dirty_pages_pct = 90
#innodb_lock_wait_timeout = 120


[mysqldump]
default-character-set = utf8
max_allowed_packet = 16M

[mysql]
no-auto-rehash
default-character-set = utf8

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

5. my.cnf 파일을 작성한다  ( default engine  innodb )

[client]
default-character-set = utf8
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8

[mysqld]
socket=/tmp/mysql.sock
datadir=/free/mysql_data
basedir = /usr/local/mysql
#user = mysql
#bind-address = 0.0.0.0
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M

#dns query
skip-name-resolve

#connection
max_connections = 1000
max_connect_errors = 1000
wait_timeout= 60

#slow-queries
#slow_query_log = /free/mysql_data/slow-queries.log
#long_query_time = 3
#log-slow-queries = /free/mysql_data/mysql-slow-queries.log

##timestamp
explicit_defaults_for_timestamp

symbolic-links=0

### log
log-error=/free/mysql_data/mysqld.log
pid-file=/tmp/mysqld.pid

###chracter
character-set-client-handshake=FALSE
init_connect = SET collation_connection = utf8_general_ci
init_connect = SET NAMES utf8
character-set-server = utf8
collation-server = utf8_general_ci

symbolic-links=0

##Password Policy
#validate_password_policy=LOW
#validate_password_policy=MEDIUM


### MyISAM Spectific options
##default-storage-engine = myisam
key_buffer_size = 32M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1


### INNODB Spectific options
default-storage-engine = InnoDB
#skip-innodb
#innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 1024MB
innodb_data_file_path = ibdata1:10M:autoextend
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 8M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

[mysqldump]
default-character-set = utf8
max_allowed_packet = 16M

[mysql]
no-auto-rehash
default-character-set = utf8

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

6.  mysql database install   ( waring) 메세지가 나타나도 무시한다

[root@localhost ~]# /usr/local/mysql/bin/mysql_install_db --user=mysql --datadir=/free/mysql_data

2015-11-27 09:51:39 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize

7.  실제 해당 디렉토리에 mysql install 되었는지 확인하자

[root@localhost ~]# ls -l /free/mysql_data
합계 469064
-rw-r----- 1 mysql mysql 56 2015-11-27 10:02 auto.cnf
-rw------- 1 root root 1675 2015-11-27 10:02 ca-key.pem
-rw------- 1 root root 944 2015-11-27 10:02 ca-req.pem
-rw------- 1 root root 1070 2015-11-27 10:02 ca.pem
-rw------- 1 root root 1078 2015-11-27 10:02 client-cert.pem
-rw------- 1 root root 1679 2015-11-27 10:02 client-key.pem
-rw------- 1 root root 948 2015-11-27 10:02 client-req.pem
-rw-r----- 1 mysql mysql 407 2015-11-27 10:02 ib_buffer_pool
-rw-r----- 1 mysql mysql 134217728 2015-11-27 10:02 ib_logfile0
-rw-r----- 1 mysql mysql 134217728 2015-11-27 10:02 ib_logfile1
-rw-r----- 1 mysql mysql 134217728 2015-11-27 10:02 ib_logfile2
-rw-r----- 1 mysql mysql 77594624 2015-11-27 10:02 ibdata1
drwxr-x--- 2 mysql mysql 4096 2015-11-27 10:02 mysql
-rw-r----- 1 mysql mysql 407 2015-11-27 10:02 mysqld.log
drwxr-x--- 2 mysql mysql 4096 2015-11-27 10:02 performance_schema
-rw------- 1 root root 1078 2015-11-27 10:02 server-cert.pem
-rw------- 1 root root 1675 2015-11-27 10:02 server-key.pem
-rw------- 1 root root 948 2015-11-27 10:02 server-req.pem
drwxr-x--- 2 mysql mysql 12288 2015-11-27 10:02 sys

8.  설치가 모두 완료되었으니 mysql 을 시작해 보자  / mysql start  / 정상적으로 올라왔다

[root@localhost ~]# mysql.server start
Starting MySQL. SUCCESS!

9.  mysql root 접속을 위해서 패스워드가 필요하다 ( 데이터베이스 생성시 자동으로 암호가 지정된다 ) 암호파일을 /root 폴더에 존재
즉 해당 작업자 디렉토리   .mysql_secret

 .mysql_secret

 

[root@localhost ~]# ls -al /root/.mysql_secret 
-rw------- 1 root root 78 2015-11-27 09:51 /root/.mysql_secret

[root@localhost ~]# cat /root/.mysql_secret 
# Password set for user 'root@localhost' at 2015-11-27 09:51:39 
GGWBtXdowyXN

10.  기록된 패스워드를 가지고 mysql 접속을 진행하자   / 접속후 환경설정을 확인하려면 에레메시지가 발생된다

You must reset your password using ALTER USER statement before executing this statement.S : CentOS 6.x (64bit)

즉 root 패스워드를 변경하라는

[root@localhost ~]# mysql -u root -p mysql
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9

Copyright (c) 2000, 2015, 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> \s
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qwer1234##$$';
Query OK, 0 rows affected (0.00 sec)

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


mysql> quit;

11.  다시 접속후 서버의 characterset 을 확인해보자

[root@localhost ~]# mysql -u root -p mysql
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.9 Source distribution

Copyright (c) 2000, 2015, 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> \s
--------------
mysql Ver 14.14 Distrib 5.7.9, for Linux (x86_64) using EditLine wrapper

Connection id: 3
Current database: mysql
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.9 Source distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 2 min 17 sec

Threads: 1 Questions: 10 Slow queries: 0 Opens: 114 Flush tables: 1 Open tables: 39 Queries per second avg: 0.072
--------------

mysql>

11. 이제 환경에 맞게 my.cnf 를 변경하면서 운용하면 된다.  패스워드 정책 low로 설정 후 다시 시작하면 된다