Compile and install MySQL5.7.5 from the source code in CentOS6.6

Source: Internet
Author: User
: Install MySQL5.7.51. install the relevant tool # yum-yinstallgcc-c ++ ncurses-develcmakemakeperlgcca by compiling and installing the source code in CentOS6.6.

Note: MySQL 5.7.5 is compiled and installed in the source code of CentOS 6.6. 1. install related tools # yum-y install gcc-c ++ ncurses-devel cmake make perl \ gcc

Notes: MySQL 5.7.5 is compiled and installed by the source code in CentOS 6.6.

1. Install related tools
# Yum-y install gcc-c ++ ncurses-devel cmake make perl \
Gcc autoconf automake zlib libxml libgcrypt libtool bison
2. Clean up the environment
Check the boost version:

# Rpm-qa boost *
Uninstall boost-* and other libraries:

# Yum-y remove boost -*
3. Download the mysql source package
Download mysql5.7 source code:

Mysql image site:

4. Create mysql users, groups, and directories
# Groupadd mysql
# Mkdir/home/mysql
# Mkdir/home/mysql/data
# Useradd-g mysql-d/home/mysql
5. Notes
The Boost library is required from MySQL 5.7.5. Download the Boost library and copy it to the/usr/local/boost directory after decompression, then re-run cmake and add option-DWITH_BOOST =/usr/local/boost in the following options
(Download :)

Boost1.57.0

Wget-c
6. Use cmake to compile and install the new version of mysq.
Decompress mysqlsource code package mysql-5.7.5-m15.tar.gz

# Tar-xzvf mysql-5.7.5-m15.tar.gz
The following operations are performed in the root directory of the decompressed source code package:

Cmake Compilation

# Cmake-DCMAKE_INSTALL_PREFIX =/home/mysql-example =/home/mysql/data-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-example = 3306-DMYSQL_USER = mysql-example = 1-Example = 1-DWITH_ARCHIVE_STORAGE_ENGINE = 1-DWITH_BLACKHOLE_STORAGE_ENGINE = 1-DWITH_MEMORY_STORAGE_ENGINE = 1-DDOWNLOAD_BOOST = 1-DWITH_BOOST =/usr/local/boost
Common parameters:

CMAKE_INSTALL_PREFIX: Specifies the installation directory of the MySQL program. The default value is/usr/local/mysql.
DEFAULT_CHARSET: Specifies the default Character Set of the server. The default value is latin1.
DEFAULT_COLLATION: Specifies the default server verification rules. The default value is latin1_general_ci.
ENABLED_LOCAL_INFILE: Specifies whether local load data infile execution is allowed. The default value is OFF.
WITH_COMMENT: Specifies the compilation remarks.
WITH_xxx_STORAGE_ENGINE: it specifies the storage engine for static compilation to mysql. By default, four engines, MyISAM, MERGE, MEMBER, and CSV, are compiled to the server, and do not need to be specified.
WITHOUT_xxx_STORAGE_ENGINE: Specifies the storage engine that is not compiled.
SYSCONFDIR: directory of the initialization parameter file
MYSQL_DATADIR: data file directory
MYSQL_TCP_PORT: Service port number. The default value is 3306.
MYSQL_UNIX_ADDR: socket file path. Default Value:/tmp/mysql. sock
Compile and install

# Make & make install
Delete the cmakecache.txt file.

# Make clean
# Rm-f CMakeCache.txt
7. Set permissions and initialize the MySQL System Authorization Table
Set permissions

# Cd/home/mysql
# Chown-R mysql.
# Chgrp-R mysql.
Add the-user = mysql parameter to the root initialization operation to generate a random password (note that the password is used for saving logon)

# Cd/home/mysql
# Bin/mysqld -- initialize -- user = mysql -- basedir =/home/mysql -- datadir =/home/mysql/data
8. Create a configuration file
Back up my. cnf generated by default

# Mv/etc/my. cnf/etc/my. cnf. bak
Enter the mysql installation directory support file directory

# Cd/home/mysql/support-files
Copy the configuration file template to the new mysql configuration file,

# Cp my-default.cnf/etc/my. cnf
You can modify the new configuration file options as needed. If you do not modify the configuration options, mysql runs based on the default configuration parameters.
The following is my configuration file/etc/my. cnf, which is used to set the encoding to utf8 to prevent garbled characters:

[Mysqld]

Character_set_server = utf8
Init_connect = 'set NAMES utf8'

[Client]
Default-character-set = utf8
9. Configure the mysql service to automatically start upon startup
Copy the Startup File to/etc/init. d/and run the command mysqld again.

# Cp/home/mysql/support-files/mysql. server/etc/init. d/mysql
Add execution permission

# Chmod 755/etc/init. d/mysqld
Check that there is no mysqld in the auto-start item list. If not, add mysqld:

# Chkconfig -- list mysqld
# Chkconfig -- add mysqld
Set MySQL to automatically start at level 345

# Chkconfig -- level 345 mysqld on
Or use this command to set the boot start:

# Chkconfig mysqld on
10. Start, restart, and stop the mysql service.
Start mysql Service

# Service mysqld start
Restart mysql Service

# Service mysqld restart
Stop mysql Service

# Service mysqld stop
11. Access the mysql database
Connect to mysql and enter the random password generated during initialization

# Mysql-uroot-p
Change the New root Password, for example, 123456.

Mysql> alter user 'root' @ 'localhost' identified by '20140901 ';
Mysql> quit;
Mysql> exit; (equivalent to the above, both exit the mysql connection)
Use the new password to reconnect to mysql

# Mysql-uroot-p

The following is the MySQL-related content carefully selected by the editor to see if it is helpful:

Install and compile MySQL5.5.28 in Linux

Install MySQL 5.6.23 in Linux

Install MySQL 5.6 with the source code in CentOS 7

How to install and configure MySQL5.7.3.0

Install MySQL in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Build a MySQL Master/Slave server in Ubuntu 14.04

Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS

Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04

MySQL-5.5.38 universal binary Installation

This article permanently updates the link address:

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.