My operating system: rhel6. The default value is base system. All available packages of development-tools selected by developmet.
Install the ncurses-devel package. My system is not installed. Install yum from the CD or rpm.
Oracle Releases Version 5.5 and uses cmake to compile the source code package. Therefore, you must install cmake. I downloaded cmake2.8, So I uninstalled cmake2.6 of the original system.
Enter the decompressed mysql directory during compilation. Check the INSTALL-SOURCE file, which describes the installation methods of mysql on various operating systems. But I did not know how to customize the installation. At this point we can open the BUILD-CMAKE file in the same directory, which describes how to use cmake to configure parameters. Therefore, we can enter cmake-L in the current directory. To view the compilation attributes with a brief explanation, we can use cmake-LH. Then we can use cmake-LAH To make all of them.
Here I write a script into the process of installing cmake and mysql:
#! /Bin/bash
Cmakever = cmake-2.8.3
Mysqlver = mysql-5.5.12
Mysql_home =/usr/local/mysql
########################
Groupadd mysql
Useradd-g mysql-s/sbin/nologin mysql
Mkdir/opt/data
Chown-R mysql. mysql/opt/data
Mkdir/usr/local/mysql
Tar zxvf unzip cmakever.tar.gz
Cd $ cmakever
./Configure; make install
Cd-
Tar zxvf running mysqlver.tar.gz
Cd $ mysqlver
Cmake.-DCMAKE_INSTALL_PREFIX = $ mysql_home \
-DINSTALL_DATADIR =/opt/data-DDEFAULT_CHARSET = utf8 \
-DEXTAR_CHARSETS = all-DENABLED_LOCAL_INFILE = 1 \
-DWITH_MYISAM_STORAGE_ENGINE = 1-DWITH_E \
MBEDDED_SERVER = 1
Make; make install
Cp-f $ mysql_home/support-files/my-medium.cnf/etc/my. cnf
Sed-e '/\ [client \]/a \ default_character_set = utf8'-E'/\ [mysqld \]/a \ character_set_server = utf8 \ n \ datadir =/opt/ data'/Etc/my. cnf>/Etc/my. cnf. new
Mv/etc/my. cnf/etc/my. cnf. old
Mv/etc/my. cnf. new/etc/my. cnf
$ Mysql_home/scripts/mysql_install_db -- datadir =/opt/data -- basedir = $ mysql_home \
-- User = mysql>/dev/null 2> & 1
#./Bin/mysqld_safe -- user = mysql &>/dev/null 2> & 1
Cp-f $ mysql_home/support-files/mysql. server/etc/init. d/mysqld
Chmod + x/etc/init. d/mysqld
Chkconfig -- add/etc/init. d/mysqld
Chkconfig -- level 35 mysqld on
Echo "export PATH = $ PATH: $ mysql_home/bin">/etc/profile
Source/etc/profile
Service mysqld start
Note: Each of the two red labels is a row. The first one is the custom compilation option, and the second is to add character encoding and data directory to my. cnf using sed. Because I customized the DATA DIRECTORY during installation. If you do not edit the default configuration file, the error always occurs in mysql_install_db.