Note: Because the mysql5.5 source package installation and the previous version of MySQL installation method is different, so write an essay record. The version of 5.5 is no longer the./configure make made install the CMake is used here, CMake is a cross-platform compilation tool.
Attention:
mysql-5.5 later versions cannot be compiled with make, only the installation can be compiled using the CMake tool.
CMAKE specifies compilation options in a different way from make.
"./configure" and "CMake." Similar
"./configure--help" and "CMake." -lh "or" ccmake. "Similar
First, install MySQL-dependent libraries in advance.
Yum install-y make Bison cmake gcc-c++ ncurses ncurses-devel
Two, download MySQL and unzip.
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.49.tar.gz
Tar zxvf mysql-5.5.49.tar.gz
CD mysql-5.5.49.tar.gz
Third, create MySQL user, DataDir.
Groupadd MySQL
Useradd-g mysql-s/sbin/nologin MySQL
Mkdir-p/data/mysql
Chown-r Mysql:mysql/data/mysql
Four, pre-compilation parameter configuration
CMake. -dcmake_install_prefix=/usr/local/mysql -dmysql_datadir=/data/mysql -ddefault_charset=utf8- Ddefault_collation=utf8_general_ci-dwith_extra_charsets:string=all-dwith_debug=0-dwith_ssl=yes-dwith_readline= 1-denabled_local_infile=1
Configuration parameter Description:
Dcmake_install_prefix=/usr/local/mysql//installation directory
-dinstall_datadir=/data/mysql//Database storage directory
-ddefault_charset=utf8//using UTF8 characters
-DDEFAULT_COLLATION=UTF8_GENERAL_CI//Check character
-dextra_charsets=all//Install all extended character sets
-denabled_local_infile=1//Allow import of data from local
Other parameter configuration can refer to http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
Five, compiling
Make
VI, installation
Make install
Seven, CD to Basedir, copy the configuration file, and initialize MySQL.
Cd/usr/local/mysql
Chown-r Mysql/usr/local/mysql
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
./scripts/mysql_install_db--user=mysql--datadir=/data/mysql
Eight, copy the startup script and add to the list of services, boot up.
CP Support-files/mysql.server/etc/init.d/mysqld
Vim/etc/init.d/mysqld specifying directories for Basedir and DataDir
chmod 755/etc/init.d/mysqld
Chkconfig--add mysqld
Chkconfig mysqld on
/etc/init.d/mysqld start
Nine, adding environment variables
echo "path= $PATH:/usr/local/mysql/bin" >/etc/profile.d/mysql.sh
Source/etc/profile
Special Note:
When you recompile, you need to clear the old object file and cache information.
# Make Clean
# rm-f CMakeCache.txt
# RM-RF/ETC/MY.CNF
Extension of knowledge:./configure and CMake differences
The./configure is the execution of a script named configure in your current directory, generated by it makefile, after the makefile, generally can be compiled by make, made install installation
CMake is a compilation tool that is the same as the make peer, except that it relies on makefile as a compilation rule and compiles it according to CMakeLists.txt.
MySQL 5.5 Source package installation