标签:
简介:
环境:虚拟机+centos6.6
Mysql版本:5.6.21
Mysql下载地址:http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.21.tar.gz
Cmake下载地址:http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz
1、安装前配置:
vi /etc/sysconfig/iptables 开启防火墙端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT 添加3306端口
Esc+:wq 退出
service iptables restart 重新启动防火墙
关闭selinux(原因我不知道,反正我在安装很多软件时候都做这个设置)
Vi /etc/selinux/config
把默认的都‘#’注销了,然后添加一条SELINUX=disabled
我把 下载好的软件包存放在 /usr/local目录下,所以读者如果在参考文档时候和自己的存放目录不一致时候请按自己的存放目录进行修改
运行yum库:
yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng* libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libX* libtiff libtiff* make mpfr ncurses* ntp openssl nasm nasm* openssl-devel patch pcre-devel perl php-common php-gd policycoreutils ppl telnet t1lib t1lib* wget zlib-devel
查看系统中是否存有旧版本的mysql,有旧版本的也让安装,但是启动mysql服务时候启动不了,所以要卸载mysql旧版本的才行,命令如下:
yum remove mysql mysql-server mysql-libs compat-mysql
我执行这条语句时候有旧版本
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
No Match for argument: mysql
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
Package(s) mysql available, but not installed.
No Match for argument: mysql-server
Package(s) mysql-server available, but not installed.
No Match for argument: compat-mysql
Resolving Dependencies
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.73-3.el6_5 will be erased
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-6.el6_5.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-6.el6_5.x86_64
--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-6.el6_5.x86_64
--> Running transaction check
---> Package postfix.x86_64 2:2.6.6-6.el6_5 will be erased
--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-12.el6.x86_64
--> Running transaction check
---> Package cronie.x86_64 0:1.4.4-12.el6 will be erased
--> Processing Dependency: cronie = 1.4.4-12.el6 for package: cronie-anacron-1.4.4-12.el6.x86_64
--> Running transaction check
---> Package cronie-anacron.x86_64 0:1.4.4-12.el6 will be erased
--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch
--> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-27.el6.x86_64
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package crontabs.noarch 0:1.10-33.el6 will be erased
---> Package sysstat.x86_64 0:9.0.4-27.el6 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================
Removing:
mysql-libs x86_64 5.1.73-3.el6_5 @anaconda-CentOS-201410241409.x86_64/6.6 4.0 M
Removing for dependencies:
cronie x86_64 1.4.4-12.el6 @anaconda-CentOS-201410241409.x86_64/6.6 174 k
cronie-anacron x86_64 1.4.4-12.el6 @anaconda-CentOS-201410241409.x86_64/6.6 43 k
crontabs noarch 1.10-33.el6 @anaconda-CentOS-201410241409.x86_64/6.6 2.4 k
postfix x86_64 2:2.6.6-6.el6_5 @anaconda-CentOS-201410241409.x86_64/6.6 9.7 M
sysstat x86_64 9.0.4-27.el6 @anaconda-CentOS-201410241409.x86_64/6.6 825 k
Transaction Summary
=======================================================================================================================================
Remove 6 Package(s)
Installed size: 15 M
需要卸载才行,反正按提示输入‘y’旧版本就卸载了,
2、安装cmake
cd /usr/local
tar zxvf cmake-3.0.2.tar.gz
执行上面命令解压;
进入cmake-3.0.2目录,
./configure 执行编译
make && make install 安装
3、安装mysql
groupadd mysql 添加mysql组
useradd -g mysql mysql -s /bin/false 添加mysql用户到mysql组中
mkdir -p /data/mysql 创建mysql的存放目录
chown -R mysql:mysql /data/mysql 设置mysql数据库的存放权限
*****如果这里出错进入到 cd /data 目录里面
chmod 777 mysql 直接赋予所有权限
mkdir -p /usr/local/mysql 创建mysql的安装目录
cd /usr/local 进入软件存放目录
tar zxvf mysql-5.6.21.tar.gz 解压mysql
cd mysql-5.6.21 进入mysql目录
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc
make && make install 编译并安装
rm -rf /etc/my.cnf 删除mysql的默认配置文件,要不然下面操作会有错误
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 赋予 mysqld 执行权限
*****如果这个操作出错 ,直接进入 cd /etc/init.d
chmod 777 mysqld 直接赋予所有权限
vi /etc/rc.d/init.d/mysqld 编辑mysqld启动项
basedir=/usr/local/mysql
datadir=/data/mysql
Esc+:+wq! 保存退出
vi /etc/profile 修改配置文件
添加 export PATH=$PATH:/usr/local/mysql/bin
Esc+:+wq!保存退出
source /etc/profile 使配置文件生效
service msyqld start
好了,mysql算是安装完毕,我们验证下
谢谢大家的支持,我在之前安装mysql时候有遇到过很多问题,在网上搜索教程很多都是抄的,本文参考 系统运维 » CentOS 6.6编译安装Nginx1.6.2+MySQL5.6.21+PHP5.6.3 结合自己的情况整理出来符合我自己的学习习惯,在此谢谢前辈不留余力的分享!
标签:
原文地址:http://www.cnblogs.com/itor/p/4548374.html