码迷,mamicode.com
首页 > 数据库 > 详细

MySQL-5.5 安装

时间:2016-05-17 13:38:58      阅读:326      评论:0      收藏:0      [点我收藏+]

标签:mysql cmake

准备工作

为了不影响实验效果,提前可以把selinux 和iptables 关闭  

[root@localhost ~]# chkconfig iptables off

[root@localhost ~]# chkconfig ip6tables off

[root@localhost ~]# /etc/init.d/iptables stop

[root@localhost ~]# /etc/init.d/ip6tables stop

[root@localhost ~]# sed -i "s/LINUX=.*/LINUX=disabled/g" /etc/selinux/config 

更改完selinux后要想生效需要重启一下服务器,reboot或者shutdown -r now 


一、安装所需组件

安装mysql所需要的组件


[root@mysql src]# yum install -y cmake

[root@mysql src]# yum install -y gcc-c++

[root@mysql src]# yum install -y gcc

[root@mysql src]# yum install -y ncurses-devel


组件说明:

cmake                  --(mysql5.5以后是通过cmake来编译的)

ncurses-devel      --执行cmake是需要依赖的包,如缺少编译报错

[root@xin-c ~]# yum instal  -y gcc gcc-c++ cmake ncurses-devel

技术分享

技术分享

二.配置mysql用户和/data/目录


[root@mysql src]# useradd -s /sbin/nologin -M mysql

[root@mysql src]# mkdir -p /data/mysql

[root@mysql src]# chown -R mysql:mysql /data/mysql


技术分享


三.下载mysql


我们从sohu的网站下载

技术分享

技术分享

点击右键。复制链接地址,然后再linux中使用wget工具下载
如果没有wget工具使用 yum install -y wget安装


[root@xin-c ~]# yum install -y wget

[root@xin-c ~]# cd /usr/local/src/

[root@xin-c src]# wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.49.tar.gz


技术分享

技术分享


[root@xin-c src]# tar -zxvf mysql-5.5.49.tar.gz


技术分享

技术分享


[root@xin-c ~]# cd /usr/local/src/mysql-5.5.49


技术分享


四.编译(cmake)


[root@xin-c mysql-5.5.49]#

cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DMYSQL_DATADIR=/data/mysql  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql  -DMYSQL_TCP_PORT=3306


技术分享

技术分享


cmake参数说明:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql                      --默认安装目录

-DINSTALL_DATADIR=/Data/Mysql                                      --数据库存放目录

-DDEFAULT_CHARSET=utf8                                                  --使用utf8字符

-DDEFAULT_COLLATION=utf8_general_ci                            --校验字符

-DEXTRA_CHARSETS=all                                                       --安装所有扩展字符集

-DENABLED_LOCAL_INFILE=1                                               --允许从本地导入数据

-DMYSQL_USER=mysql                                                         -- 指定用户

-DMYSQL_TCP_PORT=3306                                                  --指定端口

注意:在这里如果有下面报错说明你没有安装ncurses-devel

-- Configuring incomplete, errors occurred!

See also "/usr/local/src/mysql-5.5.23/CMakeFiles/CMakeOutput.log".

See also "/usr/local/src/mysql-5.5.23/CMakeFiles/CMakeError.log".

解决方法:[root@mysql src]# yum install -y ncurses-devel


在mysql5.5之前./configure 报错后再重新编译的时候需要make clean ,但是5.5以后需要rm -rf CMakeCache.txt,牢记:

[root@mysql mysql-5.5.23]# rm -rf CMakeCache.txt


[root@xin-c mysql-5.5.49]# make && make install

这个过程有点长,大家可以走动一下,一会回来再看(取决于你的服务器性能)

技术分享


五.配置


[root@xin-c data]# cd /usr/local/mysql/


技术分享



[root@xin-c mysql]# chown -R mysql:mysql /usr/local/mysql/



技术分享


初始化数据库

[root@xin-c mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql/


技术分享


[root@xin-c mysql]# cd /usr/local/mysql/support-files/

[root@xin-c support-files]# cp my-small.cnf /etc/my.cnf

[root@xin-c support-files]# cp mysql.server /etc/init.d/mysqld



技术分享


[root@xin-c support-files]# vim /etc/init.d/mysqld

找到basedir,datadir将相对应的安装目录和数据目录添加


basedir=/usr/local/mysql

datadir=/data/mysql


技术分享


[root@xin-c support-files]# /etc/init.d/mysqld stop

[root@xin-c support-files]# ps aux |grep mysql

[root@xin-c support-files]# netstat -lnp |grep 3306


技术分享

六.验证结果



[root@xin-c ~]# /usr/local/mysql/bin/mysql


技术分享



命令这么长,感觉很麻烦,定义一下PATH


[root@xin-c ~]# cd /etc/profile.d/

[root@xin-c profile.d]# vim path.sh

#!/bin/bash

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

[root@xin-c profile.d]# .  /etc/profile.d/path.sh

技术分享

ok  在试一下

技术分享

MySQL-5.5 安装

标签:mysql cmake

原文地址:http://dongxin.blog.51cto.com/3486403/1774296

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!