CentOS6.8原码安装MySQL5.6
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS6.8原码安装MySQL5.6相关的知识,希望对你有一定的参考价值。
一 安装环境
操作系统:CentOS release 6.8 (Final)
应用软件:mysql-5.6.40-linux-glibc2.12-x86_64
二 安装前准备
1、关闭Linux防火墙
[[email protected] ~]# service iptables stop
[[email protected] ~]# chkconfig iptables off
2、 关闭SELINUX
[[email protected] ~]# setenforce 0
[[email protected] ~]# vim /etc/selinux/config
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disable
3、查看已安装版本
[[email protected] ~]# rpm -qa | grep mysql
mysql-libs-5.1.73-7.el6.x86_64
4、删除旧版本
[[email protected] ~]# yum remove -y mysql-libs-5.1.73-el6.x86_64
三 下载mysql原码
1、在mysql官网https://www.mysql.com/downloads/,依次点击下载合适版本,如下图:
blob.png
blob.png
2、复制安装包的下载地址
3、下载安装包
[[email protected] ~]# wget
https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
四 MySQL安装步骤
1、添加mysql用户和组
[[email protected] ~]# groupadd -g 306 mysql
[[email protected] ~]# useradd -g 306 -u 306 -s/sbin/nologin -M mysql
2、创建mysql安装目录和数据库文件存放目录
[[email protected] ~]# mkdir /data/mysql –pv
[[email protected] ~]# mkdir /usr/local/mysql
3、解压原码
[[email protected] ~]# tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
解压文件拷贝到/usr/local/mysql下
[[email protected] ~]# cp -a mysql-5.6.40-linux-glibc2.12-x86_64/* /usr/local/mysql
4、修改属组、属主
[[email protected] local]# chown -R mysql.mysql /usr/local/mysql
[[email protected] ~]# chown -R mysql.mysql /data/mysql
5、修改配置文件
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf
[[email protected] mysql]# vim /etc/my.cnf
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
socket = /tmp/mysql.sock
log-err = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
6、初始化系统数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql
--basedir=/usr/local/mysql
7、配置mysqld服务
[email protected] ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[[email protected] ~]# chmod +x /etc/rc.d/init.d/mysqld
[[email protected] ~]# chkconfig --add mysqld
[[email protected] ~]# chkconfig mysqld on
[[email protected] ~]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
[[email protected] ~]# ln -sv /usr/local/mysql/include /usr/include/mysqld
8、设置mysql环境变量
[[email protected] ~]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh
[[email protected] ~]# source /etc/profile.d/mysql.sh
9、配置帮助文档
[[email protected] ~]# vim /etc/man.config
MANPATH /usr/local/mysql/man
10、启动mysqld服务
[[email protected] ~]# service mysqld start
以上是关于CentOS6.8原码安装MySQL5.6的主要内容,如果未能解决你的问题,请参考以下文章