mysql-5.5.59安装_MySQL-5.5 安装

准备工作

为了不影响实验效果,提前可以把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

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

二.配置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

0818b9ca8b590ca3270a3433284dd417.png

三.下载mysql

我们从sohu的网站下载

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

点击右键。复制链接地址,然后再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

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

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

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

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

0818b9ca8b590ca3270a3433284dd417.png

四.编译(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

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

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

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

0818b9ca8b590ca3270a3433284dd417.png

五.配置

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

0818b9ca8b590ca3270a3433284dd417.png

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

0818b9ca8b590ca3270a3433284dd417.png

初始化数据库

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

0818b9ca8b590ca3270a3433284dd417.png

[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

0818b9ca8b590ca3270a3433284dd417.png

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

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

basedir=/usr/local/mysql

datadir=/data/mysql

0818b9ca8b590ca3270a3433284dd417.png

[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

0818b9ca8b590ca3270a3433284dd417.png

六.验证结果

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

0818b9ca8b590ca3270a3433284dd417.png

命令这么长,感觉很麻烦,定义一下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

0818b9ca8b590ca3270a3433284dd417.png

ok  在试一下

0818b9ca8b590ca3270a3433284dd417.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值