CentOS7 compilation and installation MySQL 5.6.28 and compilation Parameters

Source: Internet
Author: User

CentOS7 compilation and installation MySQL 5.6.28 and compilation Parameters

The source code package version after MySQL 5.5 is compiled and installed using the CMake tool. Therefore, you must install the latest version of MySQL in advance. CMake is a cross-platform and open-source software build system that is used to control the software compilation process and generate independent configuration files (makefile or project). You can select the CMake compiler to install the required software during compilation. CMake official website https://cmake.org/, the latest version is 3.4.3.

CMake Installation Method

# Wget https://cmake.org/files/v3.4/cmake-3.4.3.tar.gz
# Yum install gcc-c ++ make automake

#./Bootstrap & make install

New Features of MySQL 5.6
Introduction to MySQL 5.6 On the MySQL Official Website:
MySQL5.6 is the best version in history and the world's most widely used open-source database. It provides a set of new and advanced functions, this allows us to build a new generation of network-based and embedded applications and services.
Functions and features of MySQL5.6
1. better performance and scalability
Improve the InnoDB Storage engine to bring better transaction throughput

Improved Optimization results in better query execution time and diagnosis capability

2. Online DDL/architecture operations bring better application availability
3. Improved development speed brought by access to InnoDB with NoSQL through Memcached APIs
4. Improve the high performance and self-repair cluster deployment brought about by the replication technology
5. Improved Performance Schema provides better detection and monitoring capabilities
6. Improved security control so that you do not need to worry about deploying applications
7. Other important enhancements

MySQL5.6 compilation Parameters
Official documents: http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html

Compile and install mysql-5.6.28
Step 1: Create a mysql user and group
[Root @ www ~] # Groupadd mysql
[Root @ www ~] # Useradd-r-g mysql
[Root @ www ~] # Id mysql
Uid = 996 (mysql) gid = 1000 (mysql) groups = 1000 (mysql)

[Root @ www ~] # Mkdir/usr/local/mysql
[Root @ www ~] # Mkdir/data/mysqldb

Step 2: install required software packages
[Root @ www src] # yum install gcc-c ++ ncurses-devel bison-devel

Step 3: Compile and install MySQL
1. decompress the downloaded mysql source code package and enter the decompressed directory.
The [root @ www mysql-5.6.28] # cmake .\
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_DATADIR =/data/mysqldb \
-DSYSCONFDIR =/etc \
-DMYSQL_TCP_PORT = 3306 \
-DMYSQL_UNIX_ADDR =/var/lib/mysql. sock \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DWITH_PARTITION_STORAGE_ENGINE = 1 \
-DDEFAULT_CHARSET = utf8 \
-DEXTRA_CHARSETS = all \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_DEBUG = 0

Remove cmakecache.txt from cmake.txt
[Root @ www mysql-5.6.28] # gmake
[Root @ www mysql-5.6.28] # gmake install
[Root @ www mysql-5.6.28] # ls/usr/local/mysql/
Copying readme data include man scripts SQL-scripts
INSTALL-BINARY bin docs lib mysql-test share support-files

2. Set MySQL Directory Permissions

[Root @ www mysql-5.6.28] # chown-R root: mysql/usr/local/mysql/
[Root @ www mysql-5.6.28] # chown-R mysql: mysql/data/mysqldb/

3. Install the system database

[Root @ www scripts] # chmod + x mysql_install_db
[Root @ www scripts] #./mysql_install_db -- basedir =/usr/local/mysql -- datadir =/data/mysqldb -- no-defaults -- user = mysql
[Root @ www scripts] # ls/data/mysqldb/
Ib_logfile0 ib_logfile1 ibdata1 mysql performance_schema test

4. Copy the configuration file my. cnf.
[Root @ www.mysql-5.6.28] # cd support-files/
[Root @ www support-files] # cp my-default.cnf/etc/my. cnf

[Root @ www support-files] # vim/etc/my. cnf
[Mysqld]
Basedir =/usr/local/mysql
Datadir =/data/mysqldb
Port = 3306
# Server_id = .....
Socket =/var/lib/mysql. sock

5. Copy the Startup Script

[Root @ www support-files] # cp mysql. server/etc/init. d/mysqld
[Root @ www support-files] # chmod 755/etc/init. d/mysqld
[Root @ www support-files] # chkconfig mysqld on

[Root @ www ~] # Service mysqld restart
Shutting down MySQL. SUCCESS!
Starting MySQL. SUCCESS!

[Root @ www ~] # Netstat-ntlp | grep mysqld
Tcp6 0 0: 3306: * LISTEN 20708/mysqld

6. Set mysql Environment Variables
[Root @ www ~] # Vim/etc/profile. d/path. sh
#! /Bin/bash
Export PATH = $ PATH:/usr/local/mysql/bin
[Root @ www ~] # Source/etc/profile

[Root @ www ~] # Mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 1
Server version: 5.6.28 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>

7. initialize MySQL and related security options.
[Root @ www ~] # 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 shoshould 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.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables ..
... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
To log into MySQL without having to have a user account created
Them. This is intended only for testing, and to make the installation
Go a bit smoother. You shoshould remove them before moving into
Production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root shoshould 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 shocould 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!




All done! If you 've completed all of the above steps, your MySQL
Installation shoshould now be secure.

Thanks for using MySQL!


Cleaning up...

MySQL Optimization Configuration
[Root @ www ~] # Vim/etc/my. cnf
[Mysqld]
Basedir =/usr/local/mysql
Datadir =/data/mysqldb
Port = 3306
Socket =/var/lib/mysql. sock

Key_buffer_size = 256 M
Sort_buffer_size = 2 M
Read_buffer_size = 1 M
Read_rnd_buffer_size = 8 M
Myisam_sort_buffer_size = 64 M
Net_buffer_length = 8 K

Table_open_cache = 1024
Query_cache_size = 32 M
Thread_cache_size = 8

Max_connections = 1000
Max_allowed_packet = 4 M
Tmp_table_size = 16 M
Thread_concurrency = 8
Skip-name-resolve

Interactive_timeout = 8
Wait_timeout = 8
Long_query_time = 2

Slow_query_log = on
Slow_query_log_file =/data/mysql. slow
Long_query_time = 1

[Root @ www ~] # Systemctl restart mysqld. service

Firewall Configuration
[Root @ www ~] # Firewall-cmd -- permanent -- add-port = 3306/tcp
[Root @ www ~] # Firewall-cmd -- reload

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.