Compile and install MySQL 5.6.22 in CentOS 6.5

Source: Internet
Author: User

Compile and install MySQL 5.6.22 in CentOS 6.5

Compile and install MySQL 5.6.22 in CentOS 6.5.

I. Preparations before MySQL compilation and Installation

Install the tools and libraries required for compiling the source code. (do not make any mistakes during the installation process)

Yum install gcc-c ++ ncurses-devel perl

Install cmake, download the source code from the http://www.cmake.org and compile the installation

My version: http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz

Cd/home
Tar xzvf cmake-3.0.2.tar.gz
Cd/home/cmake-3.0.2
./Bootstrap; make install
Cd ~

2. Set MySQL users and groups

New mysql user group

Groupadd mysql

New mysql user

Useradd-r-g mysql

3. Create a directory required by MySQL

Create a mysql installation directory

Mkdir-p/usr/local/mysql

Create a mysql database data file directory

Mkdir-p/data/mysqldb

4. Download and decompress the MySQL source package

Download the Source Code from http://dev.mysql.com/downloads/mysql/directly and decompress mysql-5.6.22.tar.gz (Select Source Code: Select Platform: Source Code)

Cd/home
Tar-zxv-f mysql-5.6.22.tar.gz
Cd mysql-5.6.22

V. Compile and install MySQL
From mysql 5.5, mysql source code installation began to use cmake, and the source code compilation configuration script was set.

-DCMAKE_INSTALL_PREFIX = dir_name Set the mysql installation directory
-DMYSQL_UNIX_ADDR = file_name Set the listening socket path, which must be an absolute path name. The default value is/tmp/mysql. sock.
-DDEFAULT_CHARSET = charset_name Set the character set of the server.
By default, MySQL uses the latin1 (CP1252 Western Europe) Character Set. The cmake/character_sets.cmake file contains a list of allowed character set names.
-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
-DWITH_PERFSCHEMA_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 explicitly installed.

Statically compile a storage engine to the server and use-DWITH_engine_STORAGE_ENGINE = 1

Available storage engine values include ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB), PARTITION (partitioning support), and PERFSCHEMA (Performance Schema)
-DMYSQL_DATADIR = dir_name Set the mysql database file directory
-DMYSQL_TCP_PORT = port_num Set the listening port of the mysql server. The default value is 3306.
-DENABLE_DOWNLOADS = bool Whether to download optional files. For example, if this option is enabled (set to 1), cmake downloads the test suite used by Google to run unit tests.

Set compilation Parameters

Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_UNIX_ADDR = mysql. mysql-DDEFAULT_CHARSET = gbk-DDEFAULT_COLLATION = gbk_chinese_ci-region = 1-region = 1-region = 1-DMYSQL_DATADIR =/data/mysqldb-partition = 3306-DENABLE_DOWNLOADS = 1

Note: delete the cmakecache.txt file after you refresh the configuration.

Rm CMakeCache.txt

Compile source code

Make

Install

Make install

6. Modify the directory owner and group of mysql

Modify the mysql installation directory

Cd/usr/local/mysql

Chown-R mysql: mysql.

Modify the mysql database file directory

Cd/data/mysqldb

Chown-R mysql: mysql.

VII. initialize the mysql database

<Pre name = "code" class = "plain"> cd/usr/local/mysql

Scripts/mysql_install_db -- user = mysql -- datadir =/data/mysqldb

8. Copy the mysql service startup configuration file

[SQL] view plaincopyprint? View the CODE piece derived from my CODE piece on CODE

Cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf

Cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf

Note: If the/etc/my. cnf file exists, it will be overwritten.

IX. Copy the mysql Service Startup Script and add the PATH

The following rows and rows are lost.

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

Vim/etc/profile

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

Export PATH

Source/etc/profile

10. Start the mysql service and add it to auto-start (this step is optional and you can start it yourself later)

Service mysqld start

Chkconfig -- level 35 mysqld on

11. Check whether the mysql service is enabled

Netstat-tulnp | grep 3306

Mysql-u root-p

The password is blank. If you can log on to the land, the installation is successful.

12. Modify the MySQL user root password

Mysqladmin-u root password '123'

Note: You can also run the Security Settings script to modify the root password of a MySQL user, disable root remote connection, and remove the test database and anonymous users.

/Usr/local/mysql/bin/mysql_secure_installation

13. Add a MySQL user

Grant all privileges on *. * to mysql @ "%" Identified by "123456" WITH GRANT OPTION

14. Possible Errors

Problem:

Starting MySQL .. The server quit without updating PID file ([FAILED]/mysql/Server03.mylinux.com. pid ).

Solution:

Modify datadir in/etc/my. cnf to point to the correct mysql database file directory

Problem:

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

Solution:

Create a new link or add the-S parameter to mysql to point out the location of mysql. sock.

Ln-s/usr/local/mysql/data/mysql. sock/tmp/mysql. sock

/Usr/local/mysql/bin/mysql-u root-S/usr/local/mysql/data/mysql. sock

MySQL solution:-bash: mysql: command not found

Because the mysql command path is under/usr/local/mysql/bin, When you directly use the mysql command,

The system finds this command under/usr/bin, so it cannot be found.

Solution: Make a link.

Ln-s/usr/local/mysql/bin/mysql/usr/bin

-------------------------------------- Split line --------------------------------------

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

-------------------------------------- Split line --------------------------------------

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.