Compiling MySQL 5.5 by source code in Linux and recording the installation process

Source: Internet
Author: User

From mysql 5.5, mysql source code installation began to use cmake, and compilation and installation were a little different from previous versions.

1. installation steps:

1. Preparations before installation

A. Download the mysql Source Code package. On the mysql download page, select MYSQL Community Serve Source Code version.

Note: Do not select the Linux-Generic version. This version is a compiled binary version.

B. Check whether make, bison, cmake, gcc-c ++, and ncurses are installed on Linux. If not, install the above package first. The installation method is as follows:

Note: make and gcc-c ++ are installed by default.

1. Install the make Compiler

:Http://www.gnu.org/software/make/

  1. # Tar zxvf make-3.82.tar.gz
  2. # Cd make-3.82
  3. #./Configure
  4. # Make
  5. # Make install

Also available: yum install make. i686 install this package

2. Install bison

: Http://www.gnu.org/software/bison/

  1. <Span style = "font-size: 13px;"> # tar zxvf bison-2.5.tar.gz
  2. # Cd bison-2.5
  3. #./Configure
  4. # Make
  5. # Make install </span>

Also available: yum install bison. i686 install this package

3. Install gcc-c ++

: Http://www.gnu.org/software/gcc

  1. # Tar zxvf gcc-c00000000-4.4.4.tar.gz
  2. # Cd gcc-c ++-4.4.4
  3. #./Configure
  4. # Make
  5. # Make install

Also available: yum install gcc-c ++. i686 install this package

4. Install cmake

: Http://www.cmake.org/

  1. # Tar zxvf cmake-2.8.4.tar.gz
  2. # Cd cmake-2.8.4
  3. #./Configure
  4. # Make
  5. # Make install

Also available: yum install cmake. i686 install this package

5. Install ncurses

: Http://www.gnu.org/software/ncurses/

  1. # Tar zxvf ncurses-5.8.tar.gz
  2. # Cd ncurses-5.8
  3. #./Configure
  4. # Make
  5. # Make install

Also available: yum install ncurses. i686 install this package

2. Add mysql users and groups

  1. # Groupadd mysql
  2. # Useradd-g mysql-s/sbin/nologin-M mysql

3. mysql source code compilation

  1. # Tar zxvf mysql-5.5.13.tar.gz
  2. # Cd mysql-5.5.13
  3. # Rm CMakeCache.txt
  4. # Cmake. -DCMAKE_INSTALL_PREFIX =/usr/local/mysql55/-DMYSQL_DATADIR =/usr/local/mysql55/data-plugin = 1-plugin = 3306-DMYSQL_UNIX_ADDR =/usr/local/mysql55/data /mysql. sock-DMYSQL_USER = mysql-DWITH_DEBUG = 0
  5. # Make
  6. # Make install

4. Install the database after compilation.

  1. # Cd/usr/local/mysql
  2. # Chown-R mysql.
  3. # Chgrp-R mysql.
  4. # Scripts/mysql_install_db -- user = mysql
  5. # Chown-R root.
  6. # Chown-R mysql./data

5.The following command is optional. Copy the mysql configuration file to/etc.

  1. Cp support-files/my-medium.cnf/etc/my. cnf

Change the data directory and socket file to the actual value.(Optional)

6.Start mysql:

  1. # Bin/mysqld_safe -- user = mysql &
  2. # Start mysql to check whether it is successful
  3. # Netstat-tnl | grep 3306
  4. # Or
  5. # Ps-aux | grep 'mysql'

7.Configure auto-start

  1. # Cp support-files/mysql. server/etc/init. d/mysqld
  2. # Chmod + x/etc/init. d/mysqld
  3. # Chkconfig-add mysqld

Or start it like this:

  1. # Add the mysql startup service to the System Service
  2. # Cp support-files/mysql. server/etc/init. d/mysql. server
  3. # Use the following command to start mysql
  4. # Service mysql. server start
  5. # Stop the mysql Service
  6. # Service mysql. server stop
  7. # Restart the mysql Service
  8. # Service mysql. server restart

For convenience, add the bin directory of mysql to the PATH export PATH =/usr/local/mysql/bin: $ PATH

Appendix:

Recompilation:

Dealing with Problems Compiling MySQL

The solution to handle problems involves reconfiguring. If you do reconfigure, take note of the following:

  • If CMake is run after it has previusly been run, it may use information that was gathered during its previusinvocation. This information is stored inCMakeCache.txt. When CMakestarts up, it looks for that file and reads its contents if it exists, on the assumption that the information is still correct. Thatassumption is invalid when you reconfigure.
  • Each time you run CMake, you must run makeagain to recompile. However, you may be want to remove old object filesfrom previous builds first because they were compiled using differentconfiguration options.

To prevent old object files or configuration information from being used, run these commands on Unix before re-running CMake:

shell> make clean shell> rm CMakeCache.txt

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.