首页 > 代码库 > centos 7.0 编译 安装mysql 5.6.22 过程 未完成~~持续

centos 7.0 编译 安装mysql 5.6.22 过程 未完成~~持续

 

mysql 下载目录/usr/local/src
mysql 解压目录 /usr/local/bin/mysql

GitHub https://github.com/mysql/mysql-server

 

mysql官网的安装说明
http://dev.mysql.com/doc/refman/5.6/en/source-installation.html

安装mysql必须的要求
CMake make3.75以上 GCC 4.2.1以上 Perl
Curses ncurses-devel

 

最新3.1.1 cmake
http://www.cmake.org/

下载页面
http://www.cmake.org/download/

下载目录/usr/local/src
wget http://www.cmake.org/files/v3.1/cmake-3.1.1.tar.gz

[root@localhost src]# wget http://www.cmake.org/files/v3.1/cmake-3.1.1.tar.gz--2015-01-28 10:40:27-- http://www.cmake.org/files/v3.1/cmake-3.1.1.tar.gz正在解析主机 www.cmake.org (www.cmake.org)... 66.194.253.19正在连接 www.cmake.org (www.cmake.org)|66.194.253.19|:80... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:5959421 (5.7M) [application/x-gzip]正在保存至: “cmake-3.1.1.tar.gz”100%[======================================>] 5,959,421 494KB/s 用时 11s2015-01-28 10:40:39 (524 KB/s) - 已保存 “cmake-3.1.1.tar.gz” [5959421/5959421])

 


解压目录 /usr/local/bin/cmake-3.1.1

[root@localhost src]tar zxvf cmake-3.1.1.tar.gz -C /usr/local/bin

 

进入解压目录
[root@localhost src]# cd /usr/local/bin/cmake-3.1.1
[root@localhost cmake-3.1.1]# ls
Auxiliary CompileFlags.cmake Help
bootstrap configure Licenses
CMakeCPack.cmake CONTRIBUTING.rst Modules
CMakeCPackOptions.cmake.in Copyright.txt README.rst
CMakeGraphVizOptions.cmake CTestConfig.cmake Source
CMakeLists.txt CTestCustom.cmake.in Templates
CMakeLogo.gif DartConfig.cmake Tests
cmake_uninstall.cmake.in doxygen.config Utilities

[root@localhost cmake-3.1.1]./bootstrap
[root@localhost cmake-3.1.1]make
[root@localhost cmake-3.1.1]make install

Make
http://www.gnu.org/software/make/
下载
wget http://ftp.gnu.org/gnu/make/make-4.1.tar.gz

[root@localhost src]# wget http://ftp.gnu.org/gnu/make/make-4.1.tar.gz--2015-01-28 11:22:09-- http://ftp.gnu.org/gnu/make/make-4.1.tar.gz正在解析主机 ftp.gnu.org (ftp.gnu.org)... 208.118.235.20, 2001:4830:134:3::b正在连接 ftp.gnu.org (ftp.gnu.org)|208.118.235.20|:80... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:1878787 (1.8M) [application/x-gzip]正在保存至: “make-4.1.tar.gz”100%[======================================>] 1,878,787 33.1KB/s 用时 65s2015-01-28 11:23:16 (28.0 KB/s) - 已保存 “make-4.1.tar.gz” [1878787/1878787])

 

解压

[root@localhost src]tar zxvf make-4.1.tar.gz -C /usr/local/bin[root@localhost src]# cd /usr/local/bin/make-4.1[root@localhost make-4.1]# lsABOUT-NLS dep.h load.c README.VMSacinclude.m4 dir.c main.c README.W32aclocal.m4 doc make.1 remake.calloca.c dosbuild.bat Makefile.am remote-cstms.camiga.c expand.c Makefile.ami remote-stub.camiga.h file.c makefile.com rule.car.c filedef.h Makefile.DOS rule.harscan.c function.c Makefile.in SCOPTIONSAUTHORS getloadavg.c makefile.vms signame.cbuild.sh.in getopt1.c makeint.h SMakefilebuild_w32.bat getopt.c make.lnk strcache.ccommands.c getopt.h make_msvc_net2003.sln subproc.batcommands.h gettext.h make_msvc_net2003.vcproj testsconfig glob misc.c variable.cconfig.ami gmk-default.h NEWS variable.hconfigh.dos gmk-default.scm NMakefile version.cconfig.h.in gnumake.h output.c vmsdir.hconfig.h-vms guile.c output.h vmsfunctions.cconfig.h.W32 hash.c po vmsify.cconfigure hash.h read.c vmsjobs.cconfigure.ac implicit.c README vpath.cconfigure.bat INSTALL README.Amiga w32COPYING job.c README.customsdebug.h job.h README.DOSdefault.c loadapi.c README.OS2

 

[root@localhost make-4.1]./configure
[root@localhost make-4.1]make
[root@localhost make-4.1]make install

M4
http://www.gnu.org/software/m4/

下载
wget http://ftp.gnu.org/gnu/m4/m4-latest.tar.gz

[root@localhost src]# wget http://ftp.gnu.org/gnu/m4/m4-latest.tar.gz
--2015-01-28 11:37:14-- http://ftp.gnu.org/gnu/m4/m4-latest.tar.gz
正在解析主机 ftp.gnu.org (ftp.gnu.org)... 208.118.235.20, 2001:4830:134:3::b
正在连接 ftp.gnu.org (ftp.gnu.org)|208.118.235.20|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1820658 (1.7M) [application/x-gzip]
正在保存至: “m4-latest.tar.gz”

100%[======================================>] 1,820,658 40.8KB/s 用时 42s

2015-01-28 11:37:57 (42.6 KB/s) - 已保存 “m4-latest.tar.gz” [1820658/1820658])

解压
[root@localhost src]# tar zxvf m4-latest.tar.gz -C /usr/local/bin

cd /usr/local/bin/m4-1.4.17

[root@localhost ~]# cd /usr/local/bin/m4-1.4.17
[root@localhost m4-1.4.17]# ls
acinclude.m4 build-aux configure GNUmakefile Makefile.am tests
aclocal.m4 c-boxes.el configure.ac INSTALL Makefile.in THANKS
AUTHORS cfg.mk COPYING lib NEWS TODO
BACKLOG ChangeLog doc m4 README
bootstrap checks examples maint.mk src

[root@localhost ~]./configure
[root@localhost ~]make
[root@localhost ~]make install

 

 

 

Bison 3.0.4
http://www.gnu.org/software/bison/

http://ftp.gnu.org/gnu/bison/

下载
wget http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz

[root@localhost src]# wget http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz--2015-01-28 11:03:56-- http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz正在解析主机 ftp.gnu.org (ftp.gnu.org)... 208.118.235.20, 2001:4830:134:3::b正在连接 ftp.gnu.org (ftp.gnu.org)|208.118.235.20|:80... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:3354179 (3.2M) [application/x-gzip]正在保存至: “bison-3.0.4.tar.gz”100%[======================================>] 3,354,179 41.0KB/s 用时 71s2015-01-28 11:05:08 (45.8 KB/s) - 已保存 “bison-3.0.4.tar.gz” [3354179/3354179])

 

解压
tar zxvf bison-3.0.4.tar.gz -C /usr/local/bin

[root@localhost src]# tar zxvf bison-3.0.4.tar.gz -C /usr/local/bin


[root@localhost src]# cd /usr/local/bin/bison-3.0.4
[root@localhost bison-3.0.4]# ls
ABOUT-NLS ChangeLog-1998 djgpp lib PACKAGING src
aclocal.m4 ChangeLog-2012 doc m4 po tests
AUTHORS configure etc maint.mk README THANKS
build-aux configure.ac examples Makefile.am README-alpha TODO
cfg.mk COPYING GNUmakefile Makefile.in README-release
ChangeLog data INSTALL NEWS runtime-po

这里必须安装M4 在运行
[root@localhost bison-3.0.4]./configure

[root@localhost bison-3.0.4]make
[root@localhost bison-3.0.4]make install

 

ncurses-devel (RPM安装)
找到两个网址下载 随便来一个吧
http://pkgs.org/download/ncurses-devel
http://rpmfind.net/linux/rpm2html/search.php?query=ncurses-devel

下载
wget ftp://rpmfind.net/linux/centos/7.0.1406/os/x86_64/Packages/ncurses-devel-5.9-13.20130511.el7.x86_64.rpm

[root@localhost src]# wget ftp://rpmfind.net/linux/centos/7.0.1406/os/x86_64/Packages/ncurses-devel-5.9- 13.20130511.el7.x86_64.rpm--2015-01-28 14:28:29-- ftp://rpmfind.net/linux/centos/7.0.1406/os/x86_64/Packages/ncurses-devel-5.9- 13.20130511.el7.x86_64.rpm=> “ncurses-devel-5.9-13.20130511.el7.x86_64.rpm”正在解析主机 rpmfind.net (rpmfind.net)... 195.220.108.108正在连接 rpmfind.net (rpmfind.net)|195.220.108.108|:21... 已连接。正在以 anonymous 登录 ... 登录成功!==> SYST ... 完成。 ==> PWD ... 完成。==> TYPE I ... 完成。 ==> CWD (1) /linux/centos/7.0.1406/os/x86_64/Packages ... 完成。==> SIZE ncurses-devel-5.9-13.20130511.el7.x86_64.rpm ... 729820==> PASV ... 完成。 ==> RETR ncurses-devel-5.9-13.20130511.el7.x86_64.rpm ... 完成。长度:729820 (713K) (非正式数据)100%[======================================>] 729,820 275KB/s 用时 2.6s2015-01-28 14:28:36 (275 KB/s) - “ncurses-devel-5.9-13.20130511.el7.x86_64.rpm” 已保存 [729820]

 


安装或者升级一个rpm包
rpm -ivh rpm文件【安装】
rpm -Uvh rpm文件【更新】

[root@localhost src]# rpm -ivh ncurses-devel-5.9-13.20130511.el7.x86_64.rpm准备中... ################################# [100%]正在升级/安装...1:ncurses-devel-5.9-13.20130511.el7################################# [100%]

 


下载mysql 5.66.22
[root@localhost src]wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz
解压
[root@localhost src]tar zxvf mysql-5.6.22.tar.gz -C /usr/local/bin
进入目录
[root@localhost src]# cd /usr/local/bin/mysql-5.6.22
[root@localhost mysql-5.6.22]# ls
BUILD dbug libmysqld regex unittest
BUILD-CMAKE Docs libservices scripts VERSION
client Doxyfile-perfschema man sql vio
cmake extra mysql-test sql-bench win
CMakeLists.txt include mysys sql-common zlib
cmd-line-utils INSTALL-SOURCE mysys_ssl storage
config.h.cmake INSTALL-WIN-SOURCE packaging strings
configure.cmake libevent plugin support-files
COPYING libmysql README tests

 

 

[root@localhost mysql-5.6.22]# cmake .
-- Running cmake version 3.1.1
-- MySQL 5.6.22
-- Packaging as: mysql-5.6.22-Linux-x86_64
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- Using cmake version 3.1.1
-- Not building NDB
-- Library mysqlclient depends on OSLIBS -lpthread;m;dl
-- Library mysqlserver depends on OSLIBS -lpthread;m;crypt;dl
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: HAVE_CONFIG_H
-- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/bin/mysql-5.6.22

[root@localhost mysql-5.6.22]make
[root@localhost mysql-5.6.22]make install

默认安装路径 /usr/local/mysql/


[root@localhost mysql-5.6.22]# cd /usr/local/mysql
[root@localhost mysql]# ls
bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files

复制mysql.server到启动目录init.d
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql]# chkconfig mysql on
启动mysql
[root@localhost mysql]# service mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).

参考
http://blog.rekfan.com/articles/186.html


 

以下是参考记录而已~

错误信息:安装目录下/usr/local/mysql
[root@localhost mysql]# ls
bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
[root@localhost mysql]# cd data
[root@localhost data]# ls
localhost.localdomain.err test
[root@localhost data]# vi localhost.localdomain.err
150128 17:11:06 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2015-01-28 17:11:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --
explicit_defaults_for_timestamp server option (see documentation for more details).
2015-01-28 17:11:06 6958 [ERROR] Fatal error: Can‘t change to run as user ‘mysql‘ ; Please check that the user exists!

2015-01-28 17:11:06 6958 [ERROR] Aborting

2015-01-28 17:11:06 6958 [Note] Binlog end
2015-01-28 17:11:06 6958 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

150128 17:11:06 mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended

安装MySQL

groupadd mysql #添加mysql组

useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统

mkdir -p /data/mysql #创建MySQL数据库存放目录

chown -R mysql:mysql /data/mysql #设置MySQL数据库存放目录权限

mkdir -p /usr/local/mysql #创建MySQL安装目录

cd /usr/local/src #进入软件包存放目录

tar zxvf mysql-5.6.19.tar.gz #解压

cd mysql-5.6.19 #进入目录

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc #配置

make #编译

make install #安装

rm -rf /etc/my.cnf #删除系统默认的配置文件(如果默认没有就不用删除)

cd /usr/local/mysql #进入MySQL安装目录

./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql #生成mysql系统数据库

ln -s /usr/local/mysql/my.cnf /etc/my.cnf #添加到/etc目录的软连接

cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动

chmod 755 /etc/init.d/mysqld #增加执行权限

chkconfig mysqld on #加入开机启动

vi /etc/rc.d/init.d/mysqld #编辑

basedir=/usr/local/mysql #MySQL程序安装路径

datadir=/data/mysql #MySQl数据库存放目录

service mysqld start #启动

vi /etc/profile #把mysql服务加入系统环境变量:在最后添加下面这一行

export PATH=$PATH:/usr/local/mysql/bin

source /etc/profile

下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定mysql的库文件地址。

ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql

ln -s /usr/local/mysql/include/mysql /usr/include/mysql

mkdir /var/lib/mysql #创建目录

ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock #添加软链接

mysql_secure_installation #设置Mysql密码,根据提示按Y 回车输入2次密码

 

/etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

 

cmake .\
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_NUIX_ADDR=/var/lib/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

 

CMake Error: The source directory "/usr/local/bin/mysql-5.6.22/=/usr/etc" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

 

写的比较混乱还没有完成整理好 主要是出错了 新手玩这个好有压力~

centos 7.0 编译 安装mysql 5.6.22 过程 未完成~~持续