Install MySQL 5.7.9 through source code compilation

Source: Internet
Author: User

Install MySQL 5.7.9 through source code compilation

Install CentOS 6.3

Configure yum:
[Root @ bkjia ~] # Cd/etc/yum. repos. d/

[Root @ bkjia yum. repos. d] # mkdir

[Root @ bkjia yum. repos. d] # ls
A CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo

[Root @ bkjia yum. repos. d] # mv CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Vault.repo

[Root @ bkjia yum. repos. d] # ls
A CentOS-Media.repo

[Root @ bkjia yum. repos. d] # vi CentOS-Media.repo
# CentOS-Media.repo
#
# This repo is used to mount the default locations for a CDROM/DVD on
# CentOS-6. You can use this repo and yum to install items directly off
# Dvd iso that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# Yum -- enablerepo = c6-media [command]
#
# Or for ONLY the media repo, do this:
#
# Yum -- disablerepo = \ * -- enablerepo = c6-media [command]


C6-media
Name = CentOS-$ releasever-Media
Baseurl = file: // media/CentOS/
# File: // media/cdrom/
# File: // media/cdrecorder/
Gpgcheck = 1
Enabled = 1
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


Install the dependent package:
[Root @ bkjia yum. repos. d] # yum install-y ncurses-devel glibc gcc-c ++ libstdc ++ * libtool cmake lrzsz libaio-devel


Upload source code installation package mysql-5.7.9.tar.gzand cmake-2.8.3.tar.gz:
[Root @ bkjia yum. repos. d] # cd/export/servers/


[Root @ bkjia servers] # ls
Cmake-2.8.3.tar.gz mysql-5.7.9.tar.gz


[Root @ bkjia servers] # tar-xvf cmake-2.8.3.tar.gz


[Root @ bkjia servers] # tar-xvf mysql-5.7.9.tar.gz


[Root @ bkjia servers] # ls
Cmake-2.8.3 cmake-2.8.3.tar.gz mysql-5.7.9 mysql-5.7.9.tar.gz


[Root @ bkjia servers] # cd cmake-2.8.3


[Root @ bkjia cmake-2.8.3] # ls
Bootstrap CMakeCPack. cmake CMakeLogo.gif Copyright.txt DartConfig. cmake Example Templates
ChangeLog. manual CMakeCPackOptions. cmake. in cmake_uninstall.cmake.in CTestConfig. cmake DartLocal. conf. in Modules Tests
ChangeLog.txt CMakeGraphVizOptions. cmake CompileFlags. cmake CTestCustom. cmake. in Docs Readme.txt Utilities
Cmake.1 CMakeLists.txt configure CTestCustom. ctest. in doxygen. config Source


[Root @ bkjia cmake-2.8.3] #./configure


[Root @ bkjia cmake-2.8.3] # make & make install


[Root @ bkjia mysql] # groupadd mysql


[Root @ bkjia mysql] # useradd-r-g mysql


[Root @ bkjia export] # chown-R mysql. mysql/export/


[Root @ bkjia export] # mkdir-p data/mysql/data log tmp log dumps


An error occurred while compiling the MySQL installation package:
CMake Error at cmake/boost. cmake: 76 (MESSAGE ):
You can download it with-DDOWNLOAD_BOOST = 1-DWITH_BOOST = <directory>


This CMake script will look for boost in <directory>. If it is not there,
It will download and unpack it (in that directory) for you.


If you are inside a firewall, you may need to use an http proxy:


Ex port http_proxy = http://example.com: 80


Call Stack (most recent call first ):
Cmake/boost. cmake: 228 (COULD_NOT_FIND_BOOST)
CMakeLists.txt: 435 (INCLUDE)




-- Refreshing incomplete, errors occurred!


Download installation: wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
[Root @ bkjia export] # tar-xvf boost_1_59_0.tar.gz


[Root @ bkjia boost_000059_0] # ls
Boost boostcpp. jam boost.png bootstrap. sh index.htm INSTALL libs more status
Boost-build.jam boost.css bootstrap. bat doc index.html Jamroot license_00000.txt rst.css tools


[Root @ bkjia mysql-5.7.9] # pwd
/Export/mysql-5.7.9


[Root @ bkjia mysql-5.7.9] # cmake. -DCMAKE_INSTALL_PREFIX =/export/servers/mysql/-DMYSQL_DATADIR =/export/data/mysql/data-DSYSCONFDIR =/export/servers/mysql/etc-DWITH_INNOBASE_STORAGE_ENGINE = 1-Snapshot = -DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DMYSQL_UNIX_ADDR =/export/data/mysql/tmp/mysql. sock-DENABLED_LOCAL_INFILE = ON-DENABLED_PROFILING = ON-DWITH_DEBUG = 0-DENABLE_DTRACE = OFF-trace = 3306-DDOWNLOAD_BOOST = 1-DWITH_BOOST =/export/boost_1_59_0


-DCMAKE_INSTALL_PREFIX: Specifies the installation directory of the MySQL program. The default value is/usr/local/mysql.
-DMYSQL_DATADIR: data file directory
-DSYSCONFDIR: directory of the initialization parameter file
-DWITH_INNOBASE_STORAGE_ENGINE: Specifies static compilation to the MySQL storage engine.
-DDEFAULT_CHARSET: Default Character Set
-DMYSQL_TCP_PORT: Default port


[Root @ bkjia mysql-5.7.9] # make & make install


[Root @ bkjia bin] # pwd
/Export/servers/mysql/bin


Initialize the database:
[Root @ bkjia bin] #./mysqld -- initialize-insecure -- user = mysql -- basedir =/export/servers/mysql -- datadir =/export/data/mysql/data


Delete the default my. cnf file:
[Root @ bkjia bin] # rm-rf/etc/my. cnf

[Root @ bkjia bin] #./mysqld_safe -- defaults-file =/export/servers/mysql/etc/my. cnf &

Create a configuration file my. cnf:
[Root @ bkjia etc] # cat my. cnf
[Client]
Port = 3358
Socket =/export/data/mysql/tmp/mysql. sock


[Mysqld]
Port = 3358
Socket =/export/data/mysql/tmp/mysql. sock
Datadir =/export/data/mysql/data/




# --- GLOBAL ---#
Character-set-server = utf8
Lower_case_table_names = 1
Log-output = FILE
Log-error =/export/data/mysql/log/error. log


General_log = 0


General_log_file =/export/data/mysql/log/mysql. log
Pid-file =/export/data/mysql. pid
Slow-query-log
Slow_query_log_file =/export/data/mysql/log/slow. log
Tmpdir =/export/data/mysql/tmp
Long_query_time = 1


#--------------#


# Thread_concurrency = 16
Thread _ cache_size = 512
Table_open_cache = 16384
Table_definition_cached = 16384
Sort_buffer_size = 2 M
Join_buffer_size = 2 M
Read_buffer_size = 4 M
Read_rnd_buffer_size = 4 M
Key_buffer_size = 8 M
Myisam_sort_buffer_size = 8 M
Tmp_table_size = 64 M
Max_heap_table_size = 64 M
Open_files_limit = 65535
Query_cache_size = 0


# Add z #################
Innodb_undo_directory =/export/data/mysql/undo
Innodb_undo_tablespaces = 4
Explicit_defaults_for_timestamp = 1


# --- NETWORK ---#
Back_log = 1024
Max_allowed_packet = 16 M
Interactive_timeout = 28800
Wait_timeout = 28800
Skip-external-locking
Max-connections = 1000
Skip-name-resolve
# Read_only = 1
# --- REPL ---#
Servers-id = 360360
Log-bin = mysql-bin
Binlog_format = mixed
Expire_logs_days = 7
Relay-log = relay-log




Replicate-ignore-db = mysql. slave_master_info
Replicate-ignore-db = mysql. slave_relay_log_info
Replicate-ignore-db = mysql. slave_worker_info
Replicate-ignore-db = test
Replicate-ignore-db = information_schema
Replicate-ignore-db = performance_schema




Log_slave_updates
Skip-slave-start
Slave-parallel-workers = 4
Sync_master_info = 1
Sync_relay_log = 1
Sync_relay_log_info = 1
Relay_log_info_repository = TABLE
Master_info_repository = TABLE
# Rpl_semi_sync_master_enabled = 1
# Rpl_semi_sync_slave_enabled = 1
# Rpl_semi_sync_master_timeout = 1000


# --- INNODB ---#
Default-storage-engine = INNODB
Innodb_data_home_dir =/export/data/mysql/data
Innodb_file_per_table
Innodb_log_group_home_dir =/export/data/mysql/data
Innodb_log_files_in_group = 3
Innodb_log_file_size = 512 M
Innodb_log_buffer_size = 16 M
Innodb_flush_log_at_trx_commit = 1
Innodb_lock_wait_timeout = 120
Innodb_flush_method = O_DIRECT
Innodb_max_dirty_pages_pct = 75


# Change z #####
Sync_binlog = 1
Innodb_buffer_pool_size = 1G
Innodb_data_file_path = ibdata1: 2G; ibdata2: 2G: autoextend
Innodb_autoextend_increment = 500
Innodb_thread_concurrency = 32
Innodb_open_files = 65535
Innodb_write_io_threads = 20
Innodb_read_io_threads = 20
Innodb_spin_wait_delay = 10
Innodb_flush_neighbors = 1
Innodb_use_native_aio = 1
Innodb_io_capacity = 2000
Innodb_io_capacity_max = 6000
Relay_log_recovery = 1
# InnoDB _ additional_mem_pool_size = 128 M

# Change h #####

# Innodb_numa_interleave = ON
Innodb_lru_scan_depth = 512
Innodb_checksum_algorithm = crc32
Innodb_purge_threads = 4

[Mysqldump]
Quick
Max_allowed_packet = 16 M

[Mysql]
# Auto-rehash
# Remove the next comment character if you are not familiar with SQL
# Safe-updates
Default-character-set = utf8


[Myisamchk]
Key_buffer_size = 128 M
Sort_buffer_size = 128 M
Read_buffer = 2 M
Write_buffer = 2 M

[Mysqlhotcopy]
Interactive-timeout

[Root @ bkjia log] # ps-ef | grep mysql
Root 26374 10192 0 00:00:00 pts/1/bin/sh./mysqld_safe -- defaults-file =/export/servers/mysql/etc/my. cnf
Mysql 27460 26374 0 00:00:04 pts/1/export/servers/mysql/bin/mysqld -- defaults-file =/export/servers/mysql/etc/my. cnf -- basedir =/export/servers/mysql -- datadir =/export/data/mysql/data/-- plugin-dir =/export/servers/mysql/lib/plugin -- user = mysql -- log-error =/export/data/mysql/log/error. log -- open-files-limit = 65535 -- pid-file =/export/data/mysql. pid -- socket =/export/data/mysql/tmp/mysql. sock -- Ports = 3358

The new password is not required after the new configuration file is reinitialized: (a random password is generated by default (~ /. Mysql_secret)
[Root @ bkjia bin] #./mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 4
Server version: 5.7.9-log Source distribution

Copyright (c) 2000,201 5, 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)

Add the variable location and execute the mysql command in any directory:
[Root @ bkjia ~] # Vi. bash_profile
PATH = $ PATH: $ HOME/bin:/export/servers/mysql/bin

Export PATH
Export LANG = en_US.UTF-8

[Root @ bkjia ~] # Source. bash_profile

[Root @ bkjia ~] # Mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 6
Server version: 5.7.9-log Source distribution

Copyright (c) 2000,201 5, 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>

Configure the mysql Command Script to be started through the service:
[Root @ bkjia support-files] # pwd
/Export/mysql-5.7.9/support-files

[Root @ bkjia support-files] # cp mysql. server/etc/init. d/mysqld

[Root @ bkjia init. d] # chmod 755 mysqld

[Root @ bkjia init. d] # service mysqld start
Starting MySQL... SUCCESS!

[Root @ bkjia init. d] # service mysqld stop
Shutting down MySQL... SUCCESS!

Add the mysqld server to the auto-start item:
[Root @ bkjia ~] # Chkconfig -- list mysqld
Service mysqld supports chkconfig, but is not referenced in any runlevel (run 'chkconfig -- add mysqld ')

[Root @ bkjia ~] # Chkconfig -- add mysqld

[Root @ bkjia ~] # Chkconfig -- level 345 mysqld on

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.