Centos6.5 compile and install mysql 5.6.16 detailed tutorial, centos6.55.6.16

Source: Internet
Author: User

Centos6.5 compile and install mysql 5.6.16 detailed tutorial, centos6.55.6.16

I. Preparations before MySQL compilation and Installation

Install the tools and libraries required for compiling source code
Yum install gcc-c ++ ncurses-devel perl

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

wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz tar -xzvf cmake-2.8.10.2.tar.gz cd cmake-2.8.10.2 ./bootstrap ; make ; make install cd ~

Or
Copy codeThe Code is as follows: yum-y install wget gcc-c ++ ncurses-devel cmake make perl bison openssl-devel gcc * libxml2 libxml2-devel curl-devel libjpeg * libpng * freetype *

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/and decompress mysql-5.6.16.tar.gz

wget http://www.kakapart.com/files/mysql-5.6.16.tar.gztar -zxv -f mysql-5.6.16.tar.gzcd mysql-5.6.16 

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.

 cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DMYSQL_DATADIR=/data/mysqldb \ -DMYSQL_TCP_PORT=3306 \ -DENABLE_DOWNLOADS=1

If MySQL needs to support table store in the future, you can use the following compilation configuration script:
Copy codeThe Code is as follows: cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock-DDEFAULT_CHARSET = utf8mb4-DDEFAULT_COLLATION = bytes-rows = 1-rows = 1-rows = 1-DMYSQL_DATADIR =/data/mysqldb-rows = 3306-DENABLE_DOWNLOADS = 1

-DCMAKE_INSTALL_PREFIX = dir_name: sets the mysql installation directory.
-DMYSQL_UNIX_ADDR = file_name: sets 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 option:

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: sets the mysql database file directory.
-DMYSQL_TCP_PORT = port_num: Set the mysql server listening port. 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.
Note:Refresh the configuration and delete the cmakecache.txt file.
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/mysqldbchown -R mysql:mysql . 

VII. initialize the mysql database

 cd /usr/local/mysql scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb 

8. Copy the mysql service startup configuration file
Cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf Note: overwrite if the/etc/my. cnf file exists.

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

cp support-files/mysql.server /etc/init.d/mysqldvim /etc/profile   PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH   export PATHsource /etc/profile  

10. Start the mysql service and add the service to start automatically(This step is optional. 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 password is blank. If the password can be migrated 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, and disable the remote connection of the root user to remove the test database and anonymous users.
/Usr/local/mysql/bin/mysql_secure_installation

13. 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:
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. sockMySQL

Solution:-bash: mysql: command not found
Because the mysql command path is under/usr/local/mysql/bin, the system cannot find the command under/usr/bin when you use the mysql command directly.
SolutionYes:
Ln-s/usr/local/mysql/bin/mysql/usr/bin to link Starting MySQL... The server quit without updating PID file [FAILED] ysqldb/smartlink. pid

Solution:Delete the smartlink in the/data/mysqldb directory. run the command chmod 777-R/data/mysqldb/and restart mysqlWarning: World-writable config file '/usr/local/mysql/my. cnf 'is ignored

Solution:Chmod 644/usr/local/mysql/my. cnf: set my. cnf to read/write, and other users cannot write. The problem is solved.

The above is how to install and configure mysql 5.7.14, and I hope it will help you learn it.

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.