CentOS 6.8 compiling and installing MySQL 5.6.23

Source: Internet
Author: User
Tags percona

CentOS 6.8 compiling and installing MySQL 5.6.23

Installation environment: CentOS 6.8, MySQL 5.6.23
I. Preparations before compiling and installing MySQL

Install the tools and libraries required for compiling source code
Yum-y install gcc-c ++ ncurses-devel perl openssl-devel bison

Install cmake (remember to require cmake compilation and installation from mysql 5.5), which can be downloaded from the https://cmake.org/download.
Tar zxvfcmake-3.4.1.tar.gz
Cd cmake-3.4.1
./Bootstrap
Make & make install

2. Create directories required by users and MySQL
New mysql user
Groupadd-r mysql
Useradd-r-g mysql

Create a directory for MySQL
Mkdir-p/usr/local/mysql
Mkdir-p/data/mysqldb

Iii. Compile and install MySQL

Mysql source code can be downloaded from the http://dev.mysql.com/downloads/mysql.
Tar zxvf mysql-5.6.23.tar.gz
Cd mysql-5.6.23
Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_ARCHIVE_STORAGE_ENGINE = 1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1 \
-DMYSQL_DATADIR =/data/mysqldb \
-DMYSQL_TCP_PORT = 3306 \
-DENABLE_DOWNLOADS = 1 \
-DSYSCONFDIR =/etc \
-DWITH_SSL = system \
-DWITH_ZLIB = system \
-DWITH_LIBWRAP = 0
Make & make install

DCMAKE_INSTALL_PREFIX = dir_name Set the mysql installation directory
-DDEFAULT_CHARSET = charset_name Set the character set of the server. By default, MySQL uses the latin1 (CP1252 Western Europe) Character Set
-DDEFAULT_COLLATION = collation_name Set the server's sorting rules.

-DWITH_INNOBASE_STORAGE_ENGINE = 1

-DWITH_ARCHIVE_STORAGE_ENGINE = 1

-DWITH_BLACKHOLE_STORAGE_ENGINE = 1

Storage engine options: MyISAM, MERGE, MEMORY, and CSV engines are compiled to the server by default and do not need to be installed explicitly.
-DMYSQL_DATADIR = dir_name Set the mysql database file directory
-DSYSCONFDIR Set my. cnf location

Modify mysql Directory Permissions
Cd/usr/local/mysql
Chown-R mysql: mysql.
Cd/data/mysqldb
Chown-R mysql: mysql.

Initialize the mysql database
Cd/usr/local/mysql
./Scripts/mysql_install_db -- user = mysql -- datadir =/data/mysqldb

Edit MySQL configuration file
Mv/etc/my. cnf/etc/my. cnf. bak

Edit my. cnf. my. cnf can be generated on percona official website and based on your own situation. URL: https://tools.percona.com/wizard.
[Mysql]

# CLIENT #
Port = 3306
Socket =/data/mysqldb/mysql. sock

[Mysqld]

# GENERAL #
User = mysql
Default-storage-engine = InnoDB
Socket =/data/mysqldb/mysql. sock
Pid-file =/data/mysqldb/mysql. pid

# MyISAM #
Key-buffer-size = 32 M
Myisam-recover = FORCE, BACKUP

# SAFETY #
Max-allowed-packet = 16 M
Max-connect-errorrs = 1000000

# Data storage #
Datadir =/data/mysqldb/

# Binary logging #
Log-bin =/data/mysqldb/mysql-bin
Expire-logs-days = 14
Sync-binlog = 1

# REPLICATION #
Skip-slave-start = 1
Relay-log =/data/mysqldb/relay-bin
Slave-net-timeout = 60

# Caches and limits #
Tmp-table-size = 32 M
Max-heap-table-size = 32 M
Query-cache-type = 0
Query-cache-size = 0
Max-connections = 500
Thread-cache-size = 50
Open-files-limit = 65535
Table-definition-cache = 4096
Table-open-cache = 4096

# INNODB #
Innodb-flush-method = O_DIRECT
Innodb-log-files-in-group = 2
Innodb-log-file-size = 64 M
Innodb-flush-log-at-trx-commit = 1
Innodb-file-per-table = 1
Innodb-buffer-pool-size = 592 M

# LOGGING #
Log-error =/data/mysqldb/mysql-error.log
Log-queries-not-using-indexes = 1
Slow-query-log = 1
Slow-query-log-file =/data/mysqldb/mysql-slow.log

Copy the MySQL Startup File and its command and add it to PATH

Cp support-files/mysql. server/etc/init. d/mysqld
Vim/etc/profile. d/mysql. sh
PATH =/usr/local/mysql/bin:/usr/local/mysql/lib: $ PATH
Export PATH
Source/etc/profile. d/mysql. sh

Start MySQL and add a startup Item
Service mysqld start
Chkconfig mysqld on

Set MySQL logon Permissions
Drop user ''@ localhost;
Drop user ''@ hostname;
Update mysql. user set password = password ('*******');
Flush privileges;

So far, MySQL compilation and installation are complete.

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.