centos7.4系统源码编译安装mysql

源码下载地址

https://dev.mysql.com/downloads/mysql/

检测系统

rpm -qa | grep mysql / /查看系统自带mysql
yum -y remove mysql-* //卸载mysql
rpm -e --nodeps mysql-5.1.73-3.el6_5.x86_64 //卸载mysql

安装环境依赖

yum install gcc gcc-c++ ncurses ncurses-devel bison libgcrypt perl cmake

准备boost库

tar -zxvf boost_1_59_0.tar.gz
mv boost_1_59_0 /usr/local/boost

然后创建用户组以及用户

cat /etc/group | grep mysql //查看是否存在mysql用户组
cat /etc/passwd | grep mysql //查看是否存在mysql用户
groupadd mysql //创建用户组
useradd -r -g mysql mysql //创建用户

创建文件目录

mkdir /usr/local/mysql
mkdir /usr/local/mysql/data
mkdir /usr/local/mysql/logs
mkdir /usr/local/mysql/pids
chown -R mysql:mysql /usr/local/mysql //赋予用户组

安装cmake

tar -zxvf cmake-3.6.2.tar.gz
cd cmake-3.6.2
./bootstrap
gmake
在这里插入图片描述
make install
在这里插入图片描述
查看cmake
在这里插入图片描述

解压MySql5.7.31

tar -zxvf mysql-5.7.31.tar.gz
cd mysql-5.7.31

执行Cmake编译安装MySql

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost

这里出现了问题

在这里插入图片描述

解决方案

yum -y install ncurses-devel //安装依赖
rm -rf build //删除之前

再次执行cmake,成功

在这里插入图片描述

编译安装

make && make install

安装成功
在这里插入图片描述

配置配置文件

cd /usr/local/mysql
mkdir etc
cd etc
vim my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[client]
port=3306
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/usr/local/mysql/logs/mysqld.log
pid-file=/usr/local/mysql/pids/mysqld.pid

配置环境变量

vim /etc/profile
export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
source /etc/profile

配置开机自启

cp support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld //需要root权限
chkconfig mysqld on //开机自启

启动MySQL

//初始化操作 --initialize-insecure 初始密码为空
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
//启动mysql
/etc/init.d/mysqld start
在这里插入图片描述

设置密码,配置远程连接

mysql -u root
mysql> use mysql;
mysql>update user set authentication_string=password(‘123456’) where user=‘root’ and Host = ‘localhost’;
mysql> FLUSH PRIVILEGES;
mysql>grant all privileges on . to ‘root’@’%’ identified by ‘123456’ with grant option;
mysql> FLUSH PRIVILEGES;

开放端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload //重启
//查看已开放端口
firewall-cmd --list-ports
在这里插入图片描述

远程连接测试

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值