Centos6.6 compile and install mysql5.7.5 _ MySQL from the source code

Source: Internet
Author: User
1 install related tools yum-yinstallgcc-c ++ ncurses-develcmakemakeperlgccautoconfautomakezliblibxmllibgcryptlibtoolbison2 clean up environment check boost version: rpm-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:
Http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.5-m15.tar.gz
Mysql image site:
Http://mirrors.sohu.com/mysql/

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: http://sourceforge.net/projects/boost/files/boost)

Boost1.57.0

wget -c http://liquidtelecom.dl.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.tar.gz
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 -DMYSQL_DATADIR=/home/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=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. default value:/usr/local/mysqlDEFAULT_CHARSET: specifies the default server character set. default value: latin1DEFAULT_COLLATION. default value: latin1_general_cienabled_local: specify whether local load data infile execution is allowed. the default value is OFFWITH_COMMENT: specify the compilation remarks WITH_xxx_STORAGE_ENGINE: specify the storage engine for static compilation to mysql, MyISAM, MERGE, MEMBER and CSV engines are compiled to the server by default and do not need to be specified. WITHOUT_xxx_STORAGE_ENGINE: specify the storage engine SYSCONFDIR that is not compiled: initialize the parameter file directory MYSQL_DATADIR: data file directory MYSQL_TCP_PORT: service port number, default: 3306MYSQL_UNIX_ADDR: socket file path, default :/

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=utf8init_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 '000000'; mysql> quit; mysql> exit; (equivalent to the above, both exit the mysql connection)

Use the new password to reconnect to mysql

# mysql -uroot -p

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.