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/
- # Tar zxvf make-3.82.tar.gz
- # Cd make-3.82
- #./Configure
- # Make
- # Make install
Also available: yum install make. i686 install this package
2. Install bison
: Http://www.gnu.org/software/bison/
- <Span style = "font-size: 13px;"> # tar zxvf bison-2.5.tar.gz
- # Cd bison-2.5
- #./Configure
- # Make
- # Make install </span>
Also available: yum install bison. i686 install this package
3. Install gcc-c ++
: Http://www.gnu.org/software/gcc
- # Tar zxvf gcc-c00000000-4.4.4.tar.gz
- # Cd gcc-c ++-4.4.4
- #./Configure
- # Make
- # Make install
Also available: yum install gcc-c ++. i686 install this package
4. Install cmake
: Http://www.cmake.org/
- # Tar zxvf cmake-2.8.4.tar.gz
- # Cd cmake-2.8.4
- #./Configure
- # Make
- # Make install
Also available: yum install cmake. i686 install this package
5. Install ncurses
: Http://www.gnu.org/software/ncurses/
- # Tar zxvf ncurses-5.8.tar.gz
- # Cd ncurses-5.8
- #./Configure
- # Make
- # Make install
Also available: yum install ncurses. i686 install this package
2. Add mysql users and groups
- # Groupadd mysql
- # Useradd-g mysql-s/sbin/nologin-M mysql
3. mysql source code compilation
- # Tar zxvf mysql-5.5.13.tar.gz
- # Cd mysql-5.5.13
- # Rm CMakeCache.txt
- # 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
- # Make
- # Make install
4. Install the database after compilation.
- # Cd/usr/local/mysql
- # Chown-R mysql.
- # Chgrp-R mysql.
- # Scripts/mysql_install_db -- user = mysql
- # Chown-R root.
- # Chown-R mysql./data
5.The following command is optional. Copy the mysql configuration file to/etc.
- Cp support-files/my-medium.cnf/etc/my. cnf
Change the data directory and socket file to the actual value.(Optional)
6.Start mysql:
- # Bin/mysqld_safe -- user = mysql &
- # Start mysql to check whether it is successful
- # Netstat-tnl | grep 3306
- # Or
- # Ps-aux | grep 'mysql'
7.Configure auto-start
- # Cp support-files/mysql. server/etc/init. d/mysqld
- # Chmod + x/etc/init. d/mysqld
- # Chkconfig-add mysqld
Or start it like this:
- # Add the mysql startup service to the System Service
- # Cp support-files/mysql. server/etc/init. d/mysql. server
- # Use the following command to start mysql
- # Service mysql. server start
- # Stop the mysql Service
- # Service mysql. server stop
- # Restart the mysql Service
- # 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 in
CMakeCache.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