Linux CentOS6.5 under compile and install MySQL 5.6.16 "give the Force detailed tutorial"

Source: Internet
Author: User

First, compile and install MySQL before the preparatory work

Install the tools and libraries needed to compile the source code

[SQL]View Plaincopy
    1. Yum install gcc gcc-c++ ncurses-devel perl

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


[SQL]View Plaincopy
    1. wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
    2. TAR-XZVF cmake-2.8.10.2.tar.gz
    3. CD cmake-2.8.10.2
    4. ./bootstrap; make; Make install
    5. CD ~
Second, set up MySQL users and groups

New MySQL user group

[SQL]View Plaincopy
    1. Groupadd MySQL

New MySQL User

[SQL]View Plaincopy
    1. Useradd-r-G MySQL MySQL
Iii. directories required for new MySQL

New MySQL installation directory

[SQL]View Plaincopy
    1. Mkdir-p/usr/Local/mysql

New MySQL database data file directory

[SQL]View Plaincopy
    1. Mkdir-p/data/mysqldb
Download the MySQL source package and unzip it.

Download the source code directly from http://dev.mysql.com/downloads/mysql/, unzip the mysql-5.6.16.tar.gz (http://www.quseqi.com/This site is used 5.6.16 version)

[SQL]View Plaincopy
    1. wget http://www.kakapart.com/files/mysql-5.6.16.tar.gz
    2. Tar-zxv-f mysql-5.6.16.tar.gz
    3. CD mysql-5.6.16


V. Compile and install MySQL

From mysql5.5 onwards, MySQL source installation started using CMake, set the source code compilation configuration script.

Set compilation parameters

[SQL]View Plaincopy
    1. CMake \
    2. -dcmake_install_prefix=/usr/local/mysql \
    3. -dmysql_unix_addr=/usr/local/mysql/mysql.sock \
    4. -ddefault_charset=utf8 \
    5. -DDEFAULT_COLLATION=UTF8_GENERAL_CI \
    6. -dwith_innobase_storage_engine=1 \
    7. -dwith_archive_storage_engine=1 \
    8. -dwith_blackhole_storage_engine=1 \
    9. -DMYSQL_DATADIR=/DATA/MYSQLDB \
    10. -dmysql_tcp_port=3306 \
    11. -denable_downloads=1

-dcmake_install_prefix=dir_name Setting up the MySQL installation directory
-dmysql_unix_addr=file_name Set the listener socket path, which must be an absolute pathname. Default is/tmp/mysql.sock
-ddefault_charset=charset_name Sets the character set of the server.
By default, MySQL uses the latin1 (CP1252 Western European) character set. The Cmake/character_sets.cmake file contains a list of allowed character set names.
-ddefault_collation=collation_name Sets the collation of the server.
-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 the CSV engine is compiled to the server by default and does not need to be explicitly installed.

Statically compiles a storage engine to the server, using-dwith_engine_storage_engine= 1

The available storage engine values are: 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 MySQL server listening port, default to 3306
-denable_downloads=bool 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.
























Note: To rerun the configuration, you need to delete the CMakeCache.txt file

[SQL]View Plaincopy
    1. RM CMakeCache.txt

Compiling source code

[SQL]View Plaincopy
    1. Make

Installation

[SQL]View Plaincopy
    1. Make install
Vi. modifying MySQL directory Owners and Groups

Modifying the MySQL installation directory

[SQL]View Plaincopy
    1. cd/usr/Local/mysql
    2. Chown-r Mysql:mysql.

Modifying the MySQL database file directory

[SQL]View Plaincopy
    1. Cd/data/mysqldb
    2. Chown-r Mysql:mysql.
Vii. initializing MySQL Database [SQL]View Plaincopy
    1. cd/usr/Local/mysql
    2. scripts/mysql_install_db --user=mysql--datadir=/data/mysqldb
VIII. copy MySQL service startup configuration file [SQL]View Plaincopy
    1. cp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnf

Note: Overwrite if the/etc/my.cnf file exists.

IX. copy MySQL service startup script and join path path [SQL]View Plaincopy
    1. CP Support-files/mysql.server/etc/init.d/mysqld
    2. Vim/etc/profile
    3. path=/usr/local/mysql/bin:/usr/local/mysql/lib: $PATH
    4. Export PATH
    5. Source/etc/profile
Ten. Start the MySQL service and join the boot-up self-boot (Optional This step, you can start your own later)

Service mysqld Start
Chkconfig--level mysqld on

Xi. Check if the MySQL service is started [SQL]View Plaincopy
    1. NETSTAT-TULNP | grep 3306
    2. Mysql-u root-p

The password is empty and if it can be logged on, the installation is successful.

12. Modify the password of the MySQL user root [SQL]View Plaincopy
    1. Mysqladmin-u root password ' 123456 '

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

[SQL]View Plaincopy
    1. /usr/local/mysql/bin/mysql_secure_installation
13. Errors that may occur [SQL]View Plaincopy
    1. Problem:
    2. Starting MySQL. The server quit without updating PID file ([failed]/mysql/server03.mylinux.com.pid).
    3. Solve:
    4. Modify the DataDir in/etc/my.cnf, point to the correct MySQL database file directory
[SQL]View Plaincopy
    1. Problem:
    2. ERROR 2002 (HY000): Can' t connect to local MySQL server through socket '/tmp/mysql.sock ' (2)
    3. Solve:
    4. Create a new link or add the-s parameter to MySQL to directly indicate the Mysql.sock location.
    5. Ln-s/usr/Local/mysql/data/mysql.sock/tmp/mysql.sock
    6. /usr/local/mysql/bin/mysql-u root-s/usr/local/mysql/data/mysql.sock


[SQL]View Plaincopy
      1. MySQL Problem resolution:-bash:mysql:command not found
      2. Because the path to the MySQL command is under/usr/local/mysql/bin, so when you use the MySQL command directly,
      3. The system checks this command under/usr/bin, so I can't find it.
      4. The solution is:
      5. Ln-s/usr/local/mysql/bin/mysql/usr/bin make a link

Linux CentOS6.5 under compile and install MySQL 5.6.16 "give the Force detailed tutorial"

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.