CentOS8部署LNMP环境之编译安装mysql8.0.29的教程详解

一、前提

由于我安装了几次,我就不再讲述报错了,有点打脑壳!!!提前把相关依赖和报错就地解决。

1、所需源码包

mysql-8.0.19.tar.gz
boost_1_70_0.tar.gz		//安装mysql-8所需要的boost版本
rpcsvc-proto-1.4.tar.gz		//后面出错所需要的源码包

mysql-8.0.19下载地址:http://mirrors.sohu.com/mysql/
boost_1_70_0下载地址:https://dl.bintray.com/boostorg/release/1.70.0/source/
rpcsvc-proto-1.4下载地址:https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4/

2、解决依赖

[14:41:21 root@wangzhike ~]#yum install -y cmake ncurses-devel

3、存放位置

软件源代码包存放位置:/usr/local/src
源码包编译安装位置:/usr/local/软件名字

二、编译安装mysql-8.0.19

1、上传源码包

boost_1_70_0.tar.gz
mysql-8.0.19.tar.gz
rpcsvc-proto-1.4.tar.gz

2、解决rpcsvc-proto-1.4

1)、解压

[17:05:14 root@wangzhike software]#tar -zxf rpcsvc-proto-1.4.tar.gz -C /usr/local/src/

2)、一步安装

[17:09:48 root@wangzhike rpcsvc-proto-1.4]#./configure && make && make install

3、解决boost_1_70_0

[17:13:48 root@wangzhike~]# mkdir -p /usr/local/boost
[17:14:05 root@wangzhike~]# cd /usr/local/src
[17:15:02 root@wangzhike src]#cp /software/boost_1_70_0.tar.gz /usr/local/boost/
[17:26:22 root@wangzhike boost]#tar xf boost_1_70_0.tar.gz
////只上传到/usr/local/src/存放目录,解压到当前boost目录

4、创建mysql用户及组

[17:27:46 root@wangzhike ~]#groupadd mysql
[17:28:10 root@wangzhike ~]#useradd -g mysql mysql -s /bin/false
####创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
[17:28:11 root@wangzhike ~]#mkdir -p /data/mysql
####创建MySQL数据库存放目录
[17:29:13 root@wangzhike ~]#chown -R mysql:mysql /data/mysql
####设置MySQL数据库存放目录权限
[17:29:31 root@wangzhike ~]#mkdir -p /usr/local/mysql
####创建MySQL安装目录

5、安装mysql-8.0.19

1)、解压

[17:43:24 root@wangzhike software]#tar -zxf mysql-8.0.19.tar.gz -C /usr/local/src/
[17:43:47 root@wangzhike software]#cd /usr/local/src/
[17:43:53 root@wangzhike src]#cd mysql-8.0.19/

2)、安装

[17:47:01 root@wangzhike mysql-8.0.19]#cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DINSTALL_DATADIR=/data/mysql -DMYSQL_USER=mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DFORCE_INSOURCE_BUILD=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DWITH_BOOST=/usr/local/boost

若出现以下则没毛病

CMake Warning: Manually-specified variables were not used by the
project:

EXTRA_CHARSETS
INSTALL_DATADIR
MYSQL_USER
WITH_EMBEDDED_SERVER

– Build files have been written to: /usr/local/src/mysql-8.0.19

若出现以下关于rpc.h的错误
Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc

解决方法:

[17:45:47 root@wangzhike mysql-8.0.19]#find / -name rpc.h
/usr/local/src/mysql-8.0.19/extra/libevent/include/event2/rpc.h
/usr/local/src/mysql-8.0.19/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/windeps/sunrpc/rpc/rpc.h

####并将/usr/local/src/mysql-8.0.19/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/windeps/sunrpc/目录下的rpc/rpc.h拷贝到/usr/include/

如下

[17:52:57 root@wangzhike mysql-8.0.19]#cp -a /usr/local/src/mysql-8.0.19/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/windeps/sunrpc/rpc /usr/include/

3)、make && install

[17:55:20 root@wangzhike mysql-8.0.19]#make -j 3 && install
//过程超长且内存不足的会报错

等待等待等待

若报以下错则表示内存不足需要创建分区

+: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [sql/CMakeFiles/sql_gis.dir/build.make:154: sql/CMakeFiles/sql_gis.dir/gis/distance_functor.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:11144: sql/CMakeFiles/sql_gis.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

创建分区:

[19:58:37 root@wangzhike mysql-8.0.19]#dd if=/dev/zero of=/swapfile bs=1k count=2048000
2048000+0 records in
2048000+0 records out
2097152000 bytes (2.1 GB, 2.0 GiB) copied, 6.07651 s, 345 MB/s
####获取要增加的2G的SWAP文件块
[20:10:02 root@wangzhike mysql-8.0.19]#mkswap /swapfile
mkswap: /swapfile: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 2 GiB (2097147904 bytes)
no label, UUID=18a4bbb3-75d1-411b-ac0c-c87c63547509
####创建SWAP文件
[20:10:07 root@wangzhike mysql-8.0.19]#swapon /swapfile
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
####激活SWAP文件
[20:10:12 root@wangzhike mysql-8.0.19]#swapon -s
Filename        Type   Size Used Priority
/dev/sda2        partition  2144252 137300 -2
/swapfile        file   2047996 0  -3
#####查看SWAP信息是否正确
[20:10:19 root@wangzhike mysql-8.0.19]#echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab
####添加到fstab文件中让系统引导时自动启动

在重新执行make -j 3 && make install ,出现以下画面则没有报错

```bash
-- Installing: /usr/local/mysql/man/man1/comp_err.1
-- Installing: /usr/local/mysql/man/man1/ibd2sdi.1
-- Installing: /usr/local/mysql/man/man1/innochecksum.1
-- Installing: /usr/local/mysql/man/man1/lz4_decompress.1
-- Installing: /usr/local/mysql/man/man1/my_print_defaults.1
-- Installing: /usr/local/mysql/man/man1/myisam_ftdump.1
-- Installing: /usr/local/mysql/man/man1/myisamchk.1
-- Installing: /usr/local/mysql/man/man1/myisamlog.1
-- Installing: /usr/local/mysql/man/man1/myisampack.1
-- Installing: /usr/local/mysql/man/man1/mysql.1
-- Installing: /usr/local/mysql/man/man1/mysql.server.1
-- Installing: /usr/local/mysql/man/man1/mysql_config.1
-- Installing: /usr/local/mysql/man/man1/mysql_config_editor.1
-- Installing: /usr/local/mysql/man/man1/mysql_secure_installation.1
-- Installing: /usr/local/mysql/man/man1/mysql_ssl_rsa_setup.1
-- Installing: /usr/local/mysql/man/man1/mysql_tzinfo_to_sql.1
-- Installing: /usr/local/mysql/man/man1/mysql_upgrade.1
-- Installing: /usr/local/mysql/man/man1/mysqladmin.1
-- Installing: /usr/local/mysql/man/man1/mysqlbinlog.1
-- Installing: /usr/local/mysql/man/man1/mysqlcheck.1
-- Installing: /usr/local/mysql/man/man1/mysqld_multi.1
-- Installing: /usr/local/mysql/man/man1/mysqld_safe.1
-- Installing: /usr/local/mysql/man/man1/mysqldump.1
-- Installing: /usr/local/mysql/man/man1/mysqldumpslow.1
-- Installing: /usr/local/mysql/man/man1/mysqlimport.1
-- Installing: /usr/local/mysql/man/man1/mysqlman.1
-- Installing: /usr/local/mysql/man/man1/mysqlpump.1
-- Installing: /usr/local/mysql/man/man1/mysqlshow.1
-- Installing: /usr/local/mysql/man/man1/mysqlslap.1
-- Installing: /usr/local/mysql/man/man1/perror.1
-- Installing: /usr/local/mysql/man/man1/zlib_decompress.1
-- Installing: /usr/local/mysql/man/man8/mysqld.8
-- Installing: /usr/local/mysql/man/man1/mysqlrouter.1
-- Installing: /usr/local/mysql/man/man1/mysqlrouter_passwd.1
-- Installing: /usr/local/mysql/man/man1/mysqlrouter_plugin_info.1

三、初始化mysql数据库

1、修改mysql目录权限

[20:37:59 root@wangzhike mysql-8.0.19]#chown -R mysql:mysql /usr/local/mysql
[20:42:07 root@wangzhike mysql-8.0.19]#chmod -R 755 /usr/local/mysql

2、初始化mysql

[20:45:07 root@wangzhike ~]#cd /usr/local/mysql/
[20:46:43 root@wangzhike mysql]#./bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --character-set-server=utf8
2020-04-14T12:47:13.718724Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.19) initializing of server in progress as process 9893
2020-04-14T12:47:13.719367Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2020-04-14T12:47:14.855541Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rUG-.8kdw<1f
####生成mysql系统数据库。

3、修改配置文件
mysql 8.0.x默认没有配置文件,我们自己创建一个。

[20:49:41 root@wangzhike mysql]#vi /usr/local/mysql/my.cnf
添加以下内容:
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld]
port=3306
user = mysql
socket=/tmp/mysql.sock
tmpdir = /tmp
key_buffer_size=16M
max_allowed_packet=128M
default_authentication_plugin=mysql_native_password
open_files_limit = 60000
explicit_defaults_for_timestamp
server-id = 1
character-set-server = utf8
federated
max_connections = 1000
max_connect_errors = 100000
interactive_timeout = 86400
wait_timeout = 86400
sync_binlog=0
back_log=100
default-storage-engine = InnoDB
log_slave_updates = 1
[mysqldump]
quick
[client]
password="123456"
[mysqld-8.0]
sql_mode=TRADITIONAL
[mysqladmin]
force
[mysqld]
key_buffer_size=16M
service mysqld restart

:wq!保存退出
注意,service mysqld restart 这一句一定写上,默认密码为123456

其他操作

[20:53:05 root@wangzhike mysql]#ln -s /usr/local/mysql/my.cnf /etc/my.cnf
#添加到/etc目录的软连接
[20:53:12 root@wangzhike mysql]#cd
[20:53:13 root@wangzhike ~]#cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
#把Mysql加入系统启动
[20:53:21 root@wangzhike ~]#chmod 755 /etc/init.d/mysqld
#增加执行权限
[20:53:28 root@wangzhike ~]#chkconfig mysqld on
#加入开机启动

4、编辑文件

[20:53:39 root@wangzhike ~]#vi /etc/rc.d/init.d/mysqld

####找到basedir=并修改为/usr/local/mysql
####找到datadir=并修改为/data/mysql

basedir=/usr/local/mysql		#MySQL程序安装路径
datadir=/data/mysql				#MySQl数据库存放目录

5、开机启动成功

[20:54:32 root@wangzhike ~]#service mysqld start
Starting MySQL.Logging to '/data/mysql/wangzhike.err'.
. SUCCESS!		#启动成功

6、添加变量

[20:54:44 root@wangzhike ~]#vi /etc/profile

在最后一行添加export PATH=$PATH:/usr/local/mysql/bin

[20:55:37 root@wangzhike ~]#source /etc/profile			#使配置立刻生效

7、添加软连接

[20:55:44 root@wangzhike ~]#ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
[20:55:57 root@wangzhike ~]#ln -s /usr/local/mysql/include/mysql /usr/include/mysql
####以上为把myslq的库文件链接到系统默认的位置

[20:56:02 root@wangzhike ~]#mkdir /var/lib/mysql
[20:56:14 root@wangzhike ~]#ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

8、启动mysql

[21:40:14 root@wangzhike ~]#mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.19 Source distribution

Copyright (c) 2000, 2020, 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>

则表示登陆成功。

总结

到此这篇关于CentOS8部署LNMP环境之编译安装mysql-8.0.29的文章就介绍到这了,更多相关CentOS8部署LNMP环境之编译安装mysql-8.0.29内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • VMware安装Centos8系统的教程图解(中文图形化模式)

    一.软件.系统镜像 软件:VMware 14 镜像:CentOS8 , 镜像官网下载地址 : http://mirror.jdcloud.com/centos/8.0.1905/isos/x86_64/CentOS-8-x86_64-1905-dvd1.iso 桌面模式界面如下(第三部分第11步骤选择:带GUI的服务器或工作站): 二.创建虚拟机 1.打开VMware,选择创建新的虚拟机. 2.选择自定义(高级)(C),下一步. 3.下一步. 4.选择稍 后安装操作系统,下一步. 5.选择 Li

  • VMware安装Centos8系统的教程图解(命令行模式)

    一.软件.系统镜像 软件:VMware 14 镜像:CentOS8 ,镜像官网下载地址 : http://mirror.jdcloud.com/centos/8.0.1905/isos/x86_64/CentOS-8-x86_64-1905-dvd1.iso 二.创建虚拟机 1.打开VMware,选择创建新的虚拟机. 2.选择自定义(高级)(C),下一步. 3.下一步. 4.选择稍后安装操作系统,下一步. 5.选择Linux,版本,下一步. 6.根据自己的需要设置虚拟机名称和存放位置,下一步.

  • CentOS8 安装 jdk8 / java8的教程(推荐)

    前言 最开始我是想在CentOS8上使用 wget 下载,然后对它进行解压,配置环境变量,奈何搞了很长时间都没有搞好,于是放弃,使用yum直接安装. 1.安装方法 CentOS8上使用 yum 直接安装,环境变量自动配置好 2.查看是否已安装 看到下面结果,说明已经安装配置 jdk [root@localhost ~]# java -version openjdk version "1.8.0_222" OpenJDK Runtime Environment (build 1.8.0_

  • centos8安装图解(超详细教程)

    CentOS 8 官方正式发布了!CentOS 完全遵守 Red Hat 的再发行政策,并且致力与上游产品在功能上完全兼容.CentOS 对组件的修改主要是去除 Red Hat 的商标及美工图.该版本还包含全新的 RHEL upstream, CentOS Streams. 官方中文的发行说明:https://wiki.centos.org/Manuals/ReleaseNotes/CentOS8.1905 CentOS 8 的新特性 DNF 成为了默认的软件包管理器,同时 yum 仍然是可用的

  • centos8 使用yum 安装 mongodb 4.2的方法

    1.制作 repo 文件 参考 mongodb 官方的安装文档,使用下面的脚本制作Yum库安装mongodb4.2,但安装过程提示 "Failed to synchronize cache for repo 'mongodb-org-4.2'" [mongodb-org-4.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/

  • CentOS8部署LNMP环境之编译安装mysql8.0.29的教程详解

    一.前提 由于我安装了几次,我就不再讲述报错了,有点打脑壳!!!提前把相关依赖和报错就地解决. 1.所需源码包 mysql-8.0.19.tar.gz boost_1_70_0.tar.gz //安装mysql-8所需要的boost版本 rpcsvc-proto-1.4.tar.gz //后面出错所需要的源码包 mysql-8.0.19下载地址:http://mirrors.sohu.com/mysql/ boost_1_70_0下载地址:https://dl.bintray.com/boost

  • Linux下安装mysql-8.0.20的教程详解

    ** Linux下安装mysql-8.0.20 ** 环境介绍 操作系统:CentOS 7 mysql下载地址:https://dev.mysql.com/downloads/mysql/ 下载版本:https://www.jb51.net/softs/609101.html https://www.jb51.net/softs/609101.html 卸载mysql 查看是否安装过mysql,命令:find / -name mysql 如果安装过,进行卸载: 删除相关目录: 删除配置文件: 删

  • CentOS7编译安装MySQL5.7.24的教程详解

    安装依赖 (1)cmake是新版MySQL的编译工具 sudo yum install gcc gcc-c++ pcre pcre-devel openssl openssl-devel sudo yum install zlib zlib-devel cmake ncurses ncurses-devel bison bison-devel 如下的几个依赖在CentOS7中需要安装,CentOS6不需要 sudo yum install perl perl-devel autoconf 安装b

  • win10安装zip版MySQL8.0.19的教程详解

    一. 下载后解压到想安装的目录 下载地址: https://dev.mysql.com/downloads/mysql/ 二. 在安装目录中添加配置文件my.ini [mysqld] # 设置3306端口 port=3306 # 设置mysql的安装目录 basedir=D:\DevTool\MySQL-8.0.19 # 设置mysql数据库的数据的存放目录 datadir=D:\DevTool\MySQL-8.0.19\data # 允许最大连接数 max_connections=200 #

  • CentOS 6.6 源码编译安装MySQL 5.7.18教程详解

    一.添加用户和组 1.添加mysql用户组 # groupadd mysql 2.添加mysql用户 # useradd -g mysql -s /bin/nologin mysql -M 二.查看系统中是否安装mysql,如果安装需要卸载 # rpm -qa | grep mysql mysql-libs-5.1.73-3.el6_5.x86_64 # rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps 三.安装所需依赖包 # yum -y ins

  • ubuntu16.04 linux 编译安装apache2.4.33的教程详解

    下载软件包: wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.33.tar.gz wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz 首先需要安装apr和apr-util tar xf apr-1.6.

  • 源码编译安装MySQL8.0.20的详细教程

    在上篇文章给大家介绍了: MySQL8.0.20安装教程及其安装问题详细教程  https://www.jb51.net/article/186202.htm mysql8.0.20下载安装及遇到的问题(图文详解)  https://www.jb51.net/article/186208.htm CentOS7安装Mysql8.0.20步骤: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-20.html 1 概述 本文章主要讲述

  • 浅析CentOS6.8安装MySQL8.0.18的教程(RPM方式)

    今天,记录下在CentOS 6.8服务器上如何安装MySQL 8.0.18,废话不多说了,直接进入主题. 一.卸载CentOS 6.8自带的MySQL 首先,卸载CentOS 6.8服务器上自带的MySQL,在命令行中输入如下命令查看CentOS 6.8服务器自带的MySQL. [root@binghe151 src]# rpm -qa | grep -i mysql mysql-libs-5.1.73-7.el6.x86_64 可以看到,CentOS 6.8服务器中默认安装了mysql-lib

  • Linux下安装MySQL8.0.11的教程

    1. 去官网下载安装包 下载链接:点击打开链接 https://dev.mysql.com/downloads/mysql/ 如果你的系统是32位选择第一个,64位选择第二个 也可以用wget 下载 wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-i686.tar.gz 解压文件 tar -zxvf mysql-8.0.11-linux-glibc2.12-i686.tar.gz 2

  • Windows安装MySQL8.0.x 版本教程

    目录 一.下载 二.安装 1 解压 2 配置环境变量 右击此电脑选择属性 双击系统环境变量的Path 3 配置my.ini 4 命令行启动mysql WIN+R 输入cmd 进入window命令行 cd 进入安装mysql的bin目录下 5 修改登录密码 一.下载 MySQL官网下载链接:https://downloads.mysql.com/archives/community/ 选择版本后下载zip文件 博主选择的是8.0.13 二.安装 1 解压 把下载好的zip包在你想要的路径下直接解压

随机推荐