Centos 7 source code compile and install MySQL 5.6.22 (finishing article)

Source: Internet
Author: User

After reading a few documents, have not written completely. A little tidying up, re-step to compile and install MySQL on the centos7.

The installation steps are as follows:

1. Install the compilation environment

# yum-y Install gcc-gcc-c++ ncurses-devel per

# yum Install CMake

2. build mysql directory and account number, and directory properties

# mkdir-p/data/mydata

# mkdir-p/usr/local/mysql

# useradd-d/data/mydata-s/sbin/nologin-g MySQL MySQL

# CD data/mydata/

# Chown-r Mysql:mysql.

# cd/usr/local/mysql/

# Chown-r Mysql:mysql.

3. Download copy to System

# CD

# ls

Anaconda-ks.cfg mysql-5.6.22.tar.gz

4. Unzip the MySQL source package


5. compiling mysql source package

Description: from mysql5.5 ,mysql source installation started using CMake , set the source code compilation configuration script.


setting up the MySQL installation directory


set the listener socket path, which must be an absolute pathname. Default is /tmp/mysql.sock


Sets the character set of the server.
by default, MySQL uses the latin1 (CP1252 Western European) character set. The Cmake/character_setsnanake file contains a list of allowed character set names.


Sets the collation of the server.

 -dwith_archive_ Storage_engine=1

storage engine options:
 myisam merge Memory engine is compiled to the server by default and does not need to be explicitly installed.
  static compilation of a storage engine to the server, using -dwith_engine_storage_ engine= 1
  ARCHIVE, Blackhole, EXAMPLE, Federated, Innobase (InnoDB),  partition (partitioning support), Perfschema   (performance Schema)


set the MySQL database file directory


set the MySQL server listening port, default to 3306


whether you want to download the optional files. For example, if you enable this option (set to 1),cmake will download the test suite that Google uses to run unit tests.

# CD mysql-5.6.22

# Cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_unix_addr=mysql.mysql-ddefault_charset=gbk-ddefault_ Collation=gbk_chinese_ci-dwith_innobase_storage_engine=1-dwit

h_archive_storage_engine=1-dwith_blackhole_storage_engine=1-dmysql_datadir=/data/mydata-dmysql_tcp_port=3306- Denable_downloads=1

[[email protected] mysql-5.6.22]# make

[[email protected] mysql-5.6.22]# make install

6. Initialize mysql database

# CD scripts/

# ls



FATAL Error:please Install the following Perl modules before executing./MYSQL_INSTALL_DB:

Data::D umper

error during initialization, need to install Perl-module-install.noarch

# yum Install-y Perl-module-install.noarch

# scripts/mysql_install_db--user=mysql--datadir=/data/mydata

To start mysqld at boot time with to copy

Support-files/mysql.server to the right place for your system


To does so, start the server, then issue the following commands:

./bin/mysqladmin-u root password ' new-password '

./bin/mysqladmin-u root-h localhost.localdomain password ' new-password '

Alternatively you can run:


Which would also give you the option of removing the test

Databases and anonymous user created by default. This is

Strongly recommended for production servers.

See the Manual for more instructions.

You can start the MySQL daemon with:

Cd. ;./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

CD mysql-test; Perl mysql-test-run.pl

Problems at http://bugs.mysql.com/

The latest information about MySQL was available on the Web at


Support for MySQL by buying support/licenses at http://shop.mysql.com

New Default Config file was created as./my.cnf and

Would be used by default by the server when you start it.

You could edit this file to the Change server settings

7. copy mysql service and startup files


# Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld

8. Open mysqld service

[[Email protected] ~]# service mysqld start

Starting MySQL. success!

9. Add to chkconfig

[Email protected] ~]# Chkconfig

[Email protected] ~]# chkconfig--add mysqld

[Email protected] ~]# chkconfig--list

Iprdump 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Iprinit 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Iprupdate 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off

Network 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Check Port

[Email protected] ~]# NETSTAT-TULNP | grep 3306

TCP6 0 0::: 3306:::* LISTEN


10. Set Environment variables path path

[Email protected]/]# Vi/etc/profile


Path=/usr/local/mysql/bin: $PATH

Export PATH

: Wq


# Source/etc/profile

11, Enter the database error

[Email protected]/]# Mysql-uroot

ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket ' Mysql.mysql ' (2)

12. Edit my.cnf

[Email protected] ~]# VI/ETC/MY.CNF















13. Restart mysqld service

# etc/init.d/mysqld Restart

Enter the database and set the password

# Mysql–uroot

mysql> Set Password = password (' 123456 ');

Query OK, 0 rows Affected (0.00 sec)

Mysql> quit


Here, the database installation is complete.

Thank you for your Danale blog. Reference links









This article is from the "Cheng Zi" blog, make sure to keep this source http://jif521.blog.51cto.com/848361/1597899

Centos 7 source code compile and install MySQL 5.6.22 (finishing article)

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.