02-mysql-Installation
02-mysql-Installation
---- MySQL installation version
And technical documents
Mysql current common version mysql-5.6.15.tar.gz
---- MySQL compilation and Installation
1.Installation environment requirements: mysql users and groups with the ID 27. install the software make, cmake, gcc, gcc-c ++, ncurses-devel, and bison. Groupadd-g 27 mysql useradd-u 27-g mysql-s/sbin/nologin-M mysql
2.Create the installation directory/usr/local/mysql5.6, data directory/database, PID directory/var/run/mysqld, log directory/var/log/mysqld. Configuration file directory/usr/local/mysql5.6/etc
3.Cmake-LH merge cmakecache.txt, which is compiled according to the cache file in make (this is the default one, and step 4 is recommended ).
4.Define the cmakecache.txt File
Cmake \
-DCMAKE_INSTALL_PREFIX: PATH =/usr/local/mysql5.6 \ specifies the installation PATH
-DMYSQL_DATADIR: PATH =/database \ specifies the database PATH
-DSYSCONFDIR: PATH =/usr/local/mysql5.6/etc \ specify the configuration file PATH
-DWITH_DEBUG: BOOL = on: enables debugging.
5.Compile software make
6.Install the software make install
7.MySQL configuration file modification/usr/local/mysql5.6/etc/my. cnf
[Mysqld]
Basedir =/usr/local/mysql5.6
Datadir =/database
Socket =/var/run/mysqld/mysql5.6.sock
Pid-file =/var/run/mysqld/mysql5.6.pid
Port = 3307 the default value is 3306.
User = mysql
[Mysqld_safe]
Log-error =/var/log/mysqld/mysql5.6-error. log
8.Grant mysql permissions to related directories
Chown-R myslq. mysql/usr/local/mysql5.6/database/var/run/mysqld // var/log/mysqld
9.Execute the mysql_install_db script file
/Usr/local/mysql5.6/scripts/mysql_install_db -- basedir =/usr/local/mysql5.6 -- datadir =/database -- user = mysql
10.Copy the startup command file to the system directory
Cp/usr/local/mysql5.6/support-files/mysql. server/etc/rc. d/init. d/mysql5.6 or/etc/init. d/mysqld
11.Set mysql startup and myslqd startup
Chkconfig -- add mysql5.6
Service mysql5.6 start
12.Configure the environment variable to add/usr/local/mysql5u6/bin to the profile.
Export PATH = $ PATH:/usr/local/mysql5u6/bin
Make the file take effect
Source/etc/profile
03-mysql-automatic installation script
#! /Bin/bash
# Comment
#. Mysql-5.6.sh mysql-5.6.15.tar.gz
#: Set ff = unix
#: Set nobomb
Name1 = "$1"
Name2 =$ {name1/.tar.gz /}
If! Grep-qi "^ mysql"/etc/group; then
Groupadd-g 27 mysql
Fi
If! Id mysql>/dev/null 2> & 1; then
Useradd-u 27-g mysql-s/sbin/nologin-M mysql
Fi
Yum install-y make cmake gcc-c ++ ncurses-devel bison>/dev/null 2> & 1
[-D/usr/local/mysql5.6] & rm-rf/usr/local/mysql5.6
[-D/database] & rm-rf/database/* | mkdir/database
If [-d "$ name2"]; then
[-E "$ name2/CMakeCache.txt"] & rm-f "$ name2/CMakeCache.txt"
Else
Tar xf "$ name1"
Fi
Cd $ name2
# Man cmake
# Cmake-LH compile cmakecache.txt, make will compile according to this cache file
#-D
Cmake \
-DCMAKE_INSTALL_PREFIX: PATH =/usr/local/mysql5.6 \
-DMYSQL_DATADIR: PATH =/database \
-DSYSCONFDIR: PATH =/usr/local/mysql5.6/etc \
-DWITH_DEBUG: BOOL = on
Make
Make install
Mkdir/usr/local/mysql5.6/etc
Cat <! >/Usr/local/mysql5.6/etc/my. cnf
[Mysqld]
Basedir =/usr/local/mysql5.6
Datadir =/database
Socket =/var/run/mysqld/mysql5.6.sock
Pid-file =/var/run/mysqld/mysql5.6.pid
Port = 3307
User = mysql
[Mysqld_safe]
Log-error =/var/log/mysqld/mysql5.6-error. log
!
[-D/var/run/mysqld] & rm-rf/var/run/mysqld/* | mkdir/var/run/mysqld
[-D/var/log/mysqld] & rm-rf/var/log/mysqld/* | mkdir/var/log/mysqld
Chown-R mysql. mysql/usr/local/mysql5.6/database/var/run/mysqld/var/log/mysqld
/Usr/local/mysql5.6/scripts/mysql_install_db -- basedir =/usr/local/mysql5.6 -- datadir =/database -- user = mysql
Cp/usr/local/mysql5.6/support-files/mysql. server/etc/rc. d/init. d/mysql5.6
Sed-I '/conf =/c conf =/usr/local/mysql5.6/etc/my. cnf'/etc/rc. d/init. d/mysql5.6
Chkconfig -- add mysql5.6
Service mysql5.6 start