Compile and install bitsCN.com at mysql5.5 or above
Compile and install mysql 5.5 or above
The community version of mysql 5.5 and later versions uses cmake for compilation and installation. instead of using the./configure make install tool of gnu autotools.
1. system environment
Basic software, such as gcc, must be installed for both centos and debian:
Gcc * gcc-c ++ * autoconf * automake * zlib * libxml * ncurses-devel * libgcrypt * libtool *
Yum-y install
Apt-get install
2. Installation
1. Download Software
Wget http://www.cmake.org/files/v2.8/cmake-2.8.10.tar.gz
Wget http://gd.tuwien.ac.at/db/mysql/Downloads/MySQL-5.6/mysql-5.6.12.tar.gz
Preparation
1
Cd/usr/local
2
Mkdir mysql
3
Cd mysql
4
Mkdir data
5
Groupadd mysql
6
Useradd-r-g mysql
7
Mkdir/usr/local/mysql/data (data folder)
8
Chown-R mysql. mysql/usr/local/mysql/data
2 Installation
Here are the compilation parameters of cmake.
01
Tar xzvf cmake-2.8.10.tar.gz
02
Cd cmake-2.8.10
03
./Bootstrap
04
Make
05
Make install
06
Cd mysql-5.6.12
07
Cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql/
08
-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock/
09
-DDEFAULT_CHARSET = utf8/
10
-DDEFAULT_COLLATION = utf8_general_ci/
11
-DWITH_EXTRA_CHARSETS: STRING = utf8, gbk/
12
-DWITH_INNOBASE_STORAGE_ENGINE = 1/
13
-DWITH_ARCHIVE_STORAGE_ENGINE = 1/
14
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1/
15
-DWITH_PERFSCHEMA_STORAGE_ENGINE = 1/
16
-DWITH_READLINE = yes/
17
-DENABLED_LOCAL_INFILE = 1/
18
-DMYSQL_DATADIR =/usr/local/mysql/data/
19
-DMYSQL_TCP_PORT = 3306
1
Make
2
Make install
3. Change folder permissions and initialize the database
1
Cd/usr/local/mysql
2
Chown-R mysql.
3
Chgrp-R mysql.
Copy the configuration file and start
01
Cp support-files/my-medium.cnf/etc/my. cnf
02
# Initializing a table
03
Chmod 755 scripts/mysql_install_db
04
Scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data/# specify to run with the user
05
Chown-R root.
06
Chown-R mysql data
07
08
Nohup./bin/mysqld_safe -- defaults-file =/etc/my. cnf & # run in the background
09
# Start startup
10
Cp support-files/mysql. server/etc/init. d/mysql. server # system service
1
Chkconfig -- add mysql. server # start upon startup
Here, a warning is reported during startup:
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details ).
Configure explicit_defaults_for_timestamp = true in the my. cnf file.
Postscript:
1. comparison between the autotools and CMAKE parameters during mysql compilation
Italics are commonly used (the following is taken from the mysql official website) http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
Description of the parameter configure option CMake
Main installation directory -- prefix =/usr-DCMAKE_INSTALL_PREFIX =/usr
Mysqld directory -- libexecdir =/usr/sbin-DINSTALL_SBINDIR = sbin this directory relative -- prefix, equivalent to/usr/sbin, do not add a prefix (the following mark is the same as above)
Data Directory -- localstatedir =/var/lib/mysql-DMYSQL_DATADIR =/var/lib/mysql
Configuration file my. cnf directory -- sysconfdir =/etc/mysql-DSYSCONFDIR =/etc/mysql
Plug-In directory -- with-plugindir =/usr/lib64/mysql/plugin-DINSTALL_PLUGINDIR = lib64/mysql/plugin same as above
Man page directory -- mandir =/usr/share/man-DINSTALL_MANDIR = share/mysql same as above
Shared Data Directory -- sharedstatedir =/usr/share/mysql-dinstall_1_dir = share aclocal/mysql. m4 installation directory
Library installation directory -- libdir =/usr/lib64/mysql-DINSTALL_LIBDIR = lib64/mysql is the same as above
Header installation directory -- Export dedir =/usr/include/mysql-dinstall_export dedir = include/mysql is the same as above
Information document directory -- infodir =/usr/share/info-DINSTALL_INFODIR = share/info same as above
The storage engine is also installed as a plug-in. the configure method accepts the -- with-plugins parameter specified parameters to install the plug-in using commas (,) or group names, however, in CMake, each storage engine is configured separately as a parameter. The following are commonly used:
-DWITH_INNOBASE_STORAGE_ENGINE = 1 INNODB engine
-DWITH_ARCHIVE_STORAGE_ENGINE = 1 ARCHIVE engine
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1 BLACKHOLE engine
Common cmake parameters (there may be some differences between different MySQL versions, please refer to the official documentation)
-DCMAKE_INSTALL_PREFIX = point to the mysql installation directory
-DINSTALL_SBINDIR = direct sbin to the executable file directory (prefix/sbin)
-DMYSQL_DATADIR =/var/lib/mysql directs to the mysql data file directory (/var/lib/mysql)
-DSYSCONFDIR =/etc/mysql directs to the mysql configuration file directory (/etc/mysql)
-DINSTALL_PLUGINDIR = lib/mysql/plugin directs to the plug-in Directory (prefix/lib/mysql/plugin)
-DINSTALL_MANDIR = share/man points to the man document directory (prefix/share/man)
-Dinstall_1_dir = share: point to the aclocal/mysql. m4 installation directory (prefix/share)
-DINSTALL_LIBDIR = lib/mysql point to the object code Library Directory (prefix/lib/mysql)
-DINSTALL_INCLUDEDIR = include/mysql points to the header file directory (prefix/include/mysql)
-DINSTALL_INFODIR = share/info: point to the info document storage directory (prefix/share/info)
Prefix is officially recommended as/usr
Storage Engine problems
Type csv, myisam, myisammrg, heap, innobase, archive, blackhole
To enable the support for an engine:-DWITH _ _ STORAGE_ENGINE = 1
For example:
-DWITH_INNOBASE_STORAGE_ENGINE = 1
-DWITH_ARCHIVE_STORAGE_ENGINE = 1
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1
To disable the support of an engine:-DWITHOUT _ _ STORAGE_ENGINE = 1
For example:
-DWITHOUT_EXAMPLE_STORAGE_ENGINE = 1
-DWITHOUT_FEDERATED_STORAGE_ENGINE = 1
-DWITHOUT_PARTITION_STORAGE_ENGINE = 1
Library problems
-DWITH_READLINE = 1 enable readline library support (supports editable command lines)
-DWITH_SSL = system enables ssl library support (Secure Sockets Layer)
-DWITH_ZLIB = system enables libz library support (related to zib and gzib)
-DWTIH_LIBWRAP = 0 disable the libwrap Library (implements the universal TCP packaging function and is used by the network service daemon)
-DMYSQL_TCP_PORT = 3306 specify TCP port 3306
-DMYSQL_UNIX_ADDR =/tmp/mysqld. sock specifies the mysql. sock path.
-DENABLED_LOCAL_INFILE = 1 enable local data import support
-DEXTRA_CHARSETS = all enable additional character set types (default value: all)
-DDEFAULT_CHARSET = utf8: specify the default character set as utf8.
-DDEFAULT_COLLATION = utf8_general_ci: set the default sorting rule (utf8_general_ci fast/utf8_unicode_ci accurate)
-DWITH_EMBEDDED_SERVER = 1 compile embedded server support
-DMYSQL_USER = mysql-specified mysql User (mysql by default)
-DWITH_DEBUG = 0 disable debug (disabled by default)
-DENABLE_PROFILING = 0 disable Profiling analysis (enabled by default)
2. mysql compilation errors and solutions
Error 1: cocould NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
1. run yum-y install ncurses-devel in centos.
Run: apt-get install libncurses5 libncurses5-dev in ubuntu
2. delete CMakeCache.txt and run cmake again.
BitsCN.com