TypechoJoeTheme

Dcr163的博客

统计

centos7源码安装mysql5.7

2021-09-01
/
0 评论
/
181 阅读
/
正在检测是否收录...
09/01

Centos7 Mysql5.7源码安装

下载Mysql5.7

下载地址:https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-5.7.34.tar.gz

登陆进入服务器后输入下面命令,下载mysql5.7源码:
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-5.7.34.tar.gz

安装CMake

编译Mysql5.7需要用到CMake,没有CMake的先下载安装,官网https://cmake.org/download/,输入:
wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1.tar.gz

下载好后,解压tar -zxvf cmake-3.21.1.tar.gz
[root@localhost ~]# tar -zxvf cmake-3.21.1.tar.gz

进入cmake-3.21.1目录,配置:
[root@localhost ~]# cd cmake-3.21.1
[root@localhost cmake-3.21.1]# ./configure

下面提示少了依赖,我们先安装对应依赖

安装依赖gcc gcc-c++
[root@localhost cmake-3.21.1]# yum install gcc gcc-c++

安装好依赖后,继续编译:
[root@localhost cmake-3.21.1]# ./configure
配置后,又提示缺少OpenSSL,我们继续安装OpenSSL依赖

安装 openssl openssl-devel:
[root@localhost cmake-3.21.1]# yum install openssl openssl-devel

安装完毕后继续configure
[root@localhost cmake-3.21.1]# ./configure

没有报错之后,安装make && make install
[root@localhost cmake-3.21.1]# make && make install
没有发现报错,CMake就安装好了

安装Mysql5.7

先解压源码包
[root@localhost ~]# tar -zxvf mysql-boost-5.7.34.tar.gz

进入mysql-5.7.34目录
[root@localhost ~]# cd mysql-5.7.34/
开始CMake配置,先新建mysql目录和运行目录:
[root@localhost mysql-5.7.34]# mkdir /usr/local/mysql
[root@localhost mysql-5.7.34]# mkdir /usr/local/mysql/data
[root@localhost boost]# mkdir /var/run/mysqld
新建mysql用户和mysql用户组:
[root@localhost mysql-5.7.34]# groupadd mysql
[root@localhost mysql-5.7.34]# useradd -M -g mysql -s /sbin/nologin/ mysql
修改目录所有权限给mysql用户和用户组,-P参数是递归下面的所有子目录
[root@localhost mysql-5.7.34]# chown -P mysql:mysql /usr/local/mysql

开始Cmake编译Mysql

[root@localhost mysql-5.7.34]# cmake . -DWITH_BOOST=/root/mysql-5.7.34/boost/boost_1_59_0 \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306

下面编译报错了,提示 需要安装ncurses-devel这个库

  Curses library not found.  Please install appropriate package,
      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
  cmake/readline.cmake:105 (FIND_CURSES)
  cmake/readline.cmake:198 (MYSQL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:556 (MYSQL_CHECK_EDITLINE)

安装报错的依赖
[root@localhost mysql-5.7.34]# yum install ncurses-devel

安装完毕后,继续cmake编译就用上面那个编译命令;

上面的编译过程中并没有报错,可以make && make install了
[root@localhost mysql-5.7.34]# make && make install

出现上面那个的页面就是正在安装中了,等待那么几十分钟,配置好的更快

这样就安装好了。
初始化数据库
进入到安装好的mysql目录下面:
[root@localhost mysql]# cd /usr/local/mysql

初始化mysqld:
[root@localhost mysql]# bin/mysqld --initialize --user=mysql

初始化完成的时候会提示生成了一个临时的Mysql root密码

启动Mysql服务

[root@localhost mysql]# bin/mysqld_safe --user=mysql &
这里启动时报了一个错,mysqld_safe 错误:日志错误设置为“/var/log/mariadb/mariadb.log”,但是文件不存在。 为用户“mysql”创建可写。

下面我们新建这个文件,并且把所有权设置为Mysql
首页新建一个目录
[root@localhost log]# mkdir -p /var/log/mariadb/
新建报错的日志文件
[root@localhost log]# touch /var/log/mariadb/mariadb.log
把目录的所有权更改为Mysql用户
[root@localhost log]# chown -R mysql:mysql /var/log/mariadb/
创建mysql 运行的pid目录
[root@localhost mysql]# mkdir /var/run/mariadb/
更改所有权限为mysql
[root@localhost mysql]# chown mysql:mysql /var/run/mariadb/
再启动mysql服务
[root@localhost mysql]# bin/mysqld_safe --user=mysql &

启动后发现没有报错了。查询服务是否启用
[root@localhost mysql]# ps aux|grep mysq

可以看到,mysql服务已经启动,在查看3306端口是否也占用:

这时mysql服务就启动完毕
使用客户端链接服务器看看是否正常
[root@localhost mysql]# bin/mysql -uroot -p -h 127.0.0.1

输入密码后,发现链接错误 段错误 (英文Segmentation fault)
百度解决一下,说是需要修改一个源码,大约838行的函数开始:
[root@localhost mysql-5.7.34]# vim extra/libedit/libedit-20191231-3.1/src/terminal.c
libedit_private int
terminal_set(EditLine el, const char term)
{

    int i;

//下面这行需要注释

    //char buf[TC_BUFSIZE];
    char *area;
    const struct termcapstr *t;
    sigset_t oset, nset;
    int lins, cols;
    (void) sigemptyset(&nset);
    (void) sigaddset(&nset, SIGWINCH);
    (void) sigprocmask(SIG_BLOCK, &nset, &oset);

//下面这行需要更改

    //area = buf;
    area = NULL;

centos7开机自启动mysql服务

复制服务脚本

[root@localhost mysql-5.7.34]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

添加此服务到系统服务

[root@localhost mysql-5.7.34]# chkconfig --add mysqld

添加服务后,就可以使用systemctl命令进行管理了

启动服务

[root@localhost mysql-5.7.34]# systemctl start mysqld

设置服务为开机自启动

[root@localhost mysql-5.7.34]# systemctl enable mysqld

查看服务运行状态

[root@localhost mysql-5.7.34]# systemctl status mysqld

最后附上一个PDF完整的文档

Mysql5.7源码安装.pdf

MYSQL
朗读
赞(0)
版权属于:

Dcr163的博客

本文链接:

https://dcr163.cn/519.html(转载时请注明本文出处及文章链接)

评论 (0)

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. admin
    2021-08-15

    {!{data:image/webp;base64,UklGRkAOAABXRUJQVlA4WAoAAAAQAAAAAQMAKwEA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