CentOS8 编译安装 Mysql5.7.25

安装必要的运行环境

yum install -y gcc gcc-c++ bzip2-devel bzip2-libs bison perl-Module-Install.noarch libtirpc-devel ncurses ncurses-devel bison cmake 

yum install ncurses ncurses-devel bison cmake -y

yum install libtirpc-devel -y

检查cmake 是否安装

rpm -qa|grep cmake

解压boost 

cd /usr/local

wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

tar xzf boost_1_59_0.tar.gz

mv boost_1_59_0/ boost

下载mysql

cd /usr/local/src/

wget "https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.25.tar.gz"

或者 wget "https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.25.tar.gz"


tar -zxvf mysql-5.7.25.tar.gz


cd mysql-5.7.25

 建立相应目录

mkdir -p /data/mysql/data

mkdir -p /data/mysql/log/

mkdir -p /data/mysql/binlog/

mkdir -p /data/mysql/tmp/

cmake配置编译参数 

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/data/mysql/data \
-DMYSQL_UNIX_ADDR=/data/mysql/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0 \
-DWITH_SYSTEMD=1 \
-DWITH_BOOST=/usr/local/boost

编译安装

make && make install

用户组及权限

groupadd mysql

useradd mysql -s /sbin/nologin -M -g mysql

chown -R mysql.mysql /data/mysql/

配置MySQL系统环境变量

echo 'export PATH=/usr/local/src/mysql/bin:$PATH' >>/etc/profile

tail -1 /etc/profile

//export PATH=/usr/local/src/mysql/bin:$PATH


生效

source /etc/profile

初始化数据库

    #修改/etc/my.cnf文件,和5.6之前的版本不一样,5.7版本support-files目录下没有.cnf文件,因此,需要自己手动编辑

cp /etc/my.cnf /etc/my.cnf.bak

vim /etc/my.cnf


写入
[client]
port = 3689
socket = /data/mysql/tmp/mysql.sock
default-character-set = utf8

[mysqld]
port = 3689
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/data
pid-file = /data/mysql/tmp/mysql.pid
socket = /data/mysql/tmp/mysql.sock
tmpdir = /data/mysql/tmp
character_set_server = utf8
server-id = 1
max_connections = 100
max_connect_errors = 10
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
log-bin = /data/mysql/binlog/mysql-bin
log-error = /data/mysql/log/mysql-error.log

添加PID目录并给予权限

mkdir -p /var/run/mysqld

chown mysql.mysql /var/run/mysqld

初始化数据库

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

创建快捷启动级开机服务启动

cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service  /usr/lib/systemd/system/

改变 /usr/lib/systemd/system/mysqld.service 下的pid目录

将PIDFile=/var/run/mysqld/mysqld.pid 改为 PIDFile=/data/mysql/tmp/mysql.pid

加入权限

systemctl daemon-reload

systemctl enable mysqld.service

systemctl start mysqld

启动mysql创建本地管理帐号及删除无密码帐号

/usr/local/mysql/bin/mysqladmin -u root password 'orange#123'

/usr/local/mysql/bin/mysql -uroot -p'orange#123' -e "delete from mysql.user where password='';"

/usr/local/mysql/bin/mysql -uroot -p'orange#123' -e "flush privileges;"

创建用户

/usr/local/mysql57/bin/mysql -uroot -p

create user 'shoes'@'%' identified by 'Heeu#jgh%GVhb@5dGf35df12';

grant all privileges on *.* to 'orange'@'%';

flush privileges;

查看my.cnf命令

/usr/local/mysql-5.7.25/bin/mysqld --verbose --help|grep my.cnf

报错

先清除CMakeCache.txt

rm -rf CMakeCache.txt
CMake Error at rapid/plugin/group_replication/rpcgen.cmake:93 (MESSAGE):
  Could not find rpcgen

解决方法


wget https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4/rpcsvc-proto-1.4.tar.gz

tar xf rpcsvc-proto-1.4.tar.gz

cd rpcsvc-proto-1.4

./configure

make && make install
RIPRO主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
靠谱资源下载 » CentOS8 编译安装 Mysql5.7.25

发表评论

提供最优质的资源集合

立即查看 了解详情