mysql——源码部署

为什么要源码安装?

源代码编译概述:

  • 1.使用源代码安装软件的优点 获得最新的软件版本,及时修复bug 根据用户需要,灵活定制软件功能
  • 2.应用场合举例
  • 安装较新版本的应用程序时
    自由软件的最新版本大都以源码的形式最先发布
  • 当前安装的程序无法满足需要时
    编译安装可由用户自行修改、定制功能
  • 需要为应用程序添加新的功能时
    用户可以重新配置、自由修改源代码,加入新的功能

无疑,源码安装确实解决了我们在工作当中太多的疑难杂问,有源码,不烦心,选择源码,选择轻松,选择源码,无限可能,自由掌控

操作环境:

安装系统:CentOS6.5_x64
Mysql版本:mysql-5.6.38.tar.gz 环境
Cmake(跨平台构建工具):直接使用yum安装

安装前操作

依赖包安装

[root@DB ~]# yum -y install gcc gcc-c++ ncurses-devel bison boost cmake

添加mysql用户,如果有则不需要添加
如下便不需要添加

[root@DB ~]# useradd mysql
useradd: user 'mysql' already exists

查看原来系统上是否存在mysql及mysql修改依赖,有则删除
可以看到我的是有安装的

[root@DB ~]# rpm -qa |grep mysql
qt-mysql-4.6.2-26.el6_4.x86_64
mysql-5.1.73-8.el6_8.x86_64
mysql-server-5.1.73-8.el6_8.x86_64
mysql-libs-5.1.73-8.el6_8.x86_64

如果无法删除,如下图 --nodeps参数强制将其删除

[root@DB ~]# rpm -e mysql-server --nodeps
[root@DB ~]# rpm -e mysql --nodeps
[root@DB ~]# rpm -e mysql-libs --nodeps

开始mysql软件的安装

安装包我已上传好,直接开始操作
解释:cmake . 表示对当前目录进行cmake操作
&& 前后命令语句均为true的情况下,做and连接使用
版本默认为/usr/local/mysql

[root@DB ~]# ls
mysql-5.6.38.tar.gz
[root@DB ~]# tar xf mysql-5.6.38.tar.gz 
[root@DB ~]# cd mysql-5.6.38
[root@DB mysql-5.6.38]# cmake . && make && make install

执行完上述命令后,请大家耐心等待,喝茶歇息10-20分钟应该就差不多

MYSQL初始化

给权限

[root@DB mysql-5.6.38]# chown -R mysql.mysql /usr/local/mysql/

切换到/usr/local/mysql并进行初始化,之后的一系列操作皆在此目录下

[root@DB mysql-5.6.38]# cd /usr/local/mysql/
[root@DB mysql]# scripts/mysql_install_db \
> --user=mysql \
> --basedir=/usr/local/mysql/ \
> --datadir=/usr/local/mysql/data/

给mysql提供配置文件

[root@DB mysql]# cp support-files/my-default.cnf /etc/my.cnf

做启动项

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

做软链接,方便使用mysql相关命令

[root@DB mysql]# ln -s /usr/local/mysql/bin/* /usr/local/bin/

添加开机自启

[root@DB mysql]# chkconfig --add mysqld

启动并登陆mysql测试是否成功

[root@DB mysql]# service mysqld start

成功登陆(直接登录即可,mysql5.7以下默认密码为空)

[root@DB mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.38 Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

好了,mysql的源码安装到此便大功告成!

猜你喜欢

转载自blog.csdn.net/qq_49296785/article/details/108522665