Mysql系列:Mysql5.7编译安装--系统环境:Centos7 / CentOS9 Stream
Mysql系列:Mysql5.7编译安装
系统环境:Centos7 / CentOS9 Stream
1:下载mysql源码包
https://dev.mysql.com/downloads/mysql/5.7.html
downloads 选择MySQL Community Server>source_code>Generic Linux (Architecture Independent), Compressed TAR Archive -> 选择需要的mysql版本,下载xxx.tar.gz包
cd /tmp
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.43.tar.gz
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
所需资料百度网盘地址
链接:
https://pan.baidu.com/s/1-C0JPrWZVCb2opkiYEUwqQ?pwd=yyds
提取码:yyds
2:安装前准备
添加禁止登陆的mysql用户
groupadd mysql
useradd -g mysql -s /bin/nologin mysql
创建文件路径
mkdir -p /data/mysql # mysql数据路径
mkdir -p /usr/local/mysql # mysql服务路径
mkdir -p /var/run/mysql # mysql pid路径
mkdir -p /var/log/mysql # mysql log路径
安装扩展依赖
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
5.7.5以后都需要安装boost
放到 /usr/local/目录
tar xzf /tmp/boost_1_59_0.tar.gz
mv /tmp/boost_1_59_0 /usr/local/
/usr/local/boost_1_59_0/bootstrap.sh
/usr/local/boost_1_59_0/b2 install
解压
cd /tmp
tar -zxvf mysql-5.7.43.tar.gz
cd mysql-5.7.43/
3:编译安装
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/usr/local/mysql/etc \
-DMYSQL_UNIX_ADDR==/data/mysql/mysql.sock \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost_1_59_0 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DTRACE=0 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_EMBEDDED_SERVER=1 \
-DMYSQL_USER=mysql
说明:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #指定安装目录
-DMYSQL_DATADIR=/data/mysql \ #mysql数据文件存放目录
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \ #指定mysql.sock地址 -DSYSCONFDIR=/usr/local/mysql/etc MySQL配置文件路径
3.1:cmake常见问题
如果失败了,请删除CMakeCache.txt文件
1)CMake Error at cmake/boost.cmake:81 (MESSAGE): You can download it
with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=
解决:
1:
cd /usr/local/boost
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
2:cmake添加参数
-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
重新cmake编译
3.2:make安装
make && make install
3.3:make常见问题-内存不足
错误: c++: internal compiler error: Killed (program cc1plus) mysql编译安装过程内存不足,安装需要2G内存
解决:
# dd if=/dev/zero of=/swapfile bs=1k count=4096000 --获取要增加的4G的SWAP文件块
# mkswap /swapfile -- 创建SWAP文件
# swapon /swapfile -- 激活SWAP文件
# swapon -s -- 查看SWAP信息是否正确
注意, swapfile文件的路径在/var/下
编译完后, 如果不想要交换分区了, 可以删除:
# swapoff /swapfile
# rm -fr /swapfile
重新cmake -> make && make install
4:配置***/etc/my.cnf***
cp /etc/my.cnf /etc/my.cnf.bak
vim /etc/my.cnf
[client]
port = 3306
socket = /data/mysql/mysql.sock
default-character-set = utf8mb4
[mysqld]
port = 3306
user = mysql
pid-file = /var/run/mysql/mysql.pid
socket = /data/mysql/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql/
log_error = /var/log/mysql/error.log
slow_query_log = 1
long_query_time = 3
slow_query_log_file = /var/log/mysql/slow.log
performance_schema = 0
explicit_defaults_for_timestamp
secure-file-priv=''
sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
init-connect = 'SET NAMES utf8mb4'
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
5:初始化数据
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
注: 之前版本mysql_install_db是在mysql_basedir/script下,5.7放在了mysql_install_db/bin目录下,且已被废弃“–initialize”会生成一个随机密码(~/.mysql_secret),而”–initialize-insecure”不会生成密码 –datadir目标目录下不能有数据文件
6:配置环境变量
vim /etc/profile.d/mysql.sh
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
执行source让环境变量立即生效
source /etc/profile
7:将mysql 加入到systemctl中
vim /usr/lib/systemd/system/mysql.service
[Unit]
Description=The Mysql Process Manager
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/mysql/mysql.pid
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=false
[Install]
WantedBy=multi-user.target
执行:
systemctl daemon-reload
8:管理MySQL
注意,在这一步可能会遇到很多问题,请确保权限正常
chown -R mysql:mysql /data/mysql/
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /usr/share/mysql/
chmod -R 777 /var/run/mysql
启动mysql
systemctl start mysql
查看mysql状态
systemctl status mysql
停止mysql状态
systemctl stop mysql
9:配置MySQL安全配置向导mysql_secure_installation
[develop@wd87 data]$ /usr/local/mysql/bin/mysql_secure_installation
Securing the MySQL server deployment. Connecting to MySQL using a
blank password. VALIDATE PASSWORD PLUGIN can be used to test
passwords and improve security. It checks the strength of password and
allows the users to set only those passwords which are secure enough.
Would you like to setup VALIDATE PASSWORD plugin?
输入要安装验证密码插件吗?
Press y|Y for Yes, any other key for No: y There are three levels of
password validation policy: LOW Length >= 8 MEDIUM Length >= 8,
numeric, mixed case, and special characters
数字、混合大小写和特殊字符
STRONG Length >= 8, numeric, mixed case, special characters and dictionary
file
输入密码安全等级一般选择 MEDIUM
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1 Please set the
password for root here.
输入新密码
New password:
确认密码
Re-enter new password:
Estimated strength of the password: 100
输入是否继续使用提供的密码?
Do you wish to continue with the password provided? (Press y|Y for
Yes, any other key for No) : y By default, a MySQL installation has
an anonymous user, allowing anyone to log into MySQL without having to
have a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother. You should
remove them before moving into a production environment.
输入是否删除匿名用户?
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success. Normally, root should only be allowed to connect from
‘localhost’. This ensures that someone cannot guess at the root
password from the network.
输入不允许root远程登录?
Disallow root login remotely? (Press y|Y for Yes, any other key for
No) : y Success. By default, MySQL comes with a database named
‘test’ that anyone can access. This is also intended only for testing,
and should be removed before moving into a production environment.
输入删除测试数据库并访问它
Remove test database and access to it? (Press y|Y for Yes, any other
key for No) : y
- Dropping test database… Success.
- Removing privileges on test database… Success. Reloading the privilege tables will ensure that all changes made so far will take
effect immediately.
重新加载特权表将确保所有更改到目前为止所作的规定将立即生效。
Reload privilege tables now? (Press y|Y for Yes, any other key for
No) : y Success.
All done!
Mysql系列:Mysql5.7编译安装--系统环境:Centos7 / CentOS9 Stream的更多相关文章
- MySQL 系列(一)安装
MySQL 系列(一)安装 以 Centos7 下安装 MySQL 5.6 为例. 一.环境准备 (1) 下载 下载地址: https://dev.mysql.com/get/Downloads/My ...
- Linux中MySQL5.6编译安装与MySQL5.7二进制安装步骤
首先,介绍一下MySQL的几种安装方式 1.RPM.Yum 的安装方式:安装方便.安装速度快,无法定制 2.二进制:不需要安装,解压即可使用,不能定制功能 3.编译安装:可定制,安装慢. 编译安装中需 ...
- centos7.2 mysql5.5编译安装
环境 centos7.2 源码包mysql5.5.38 mysql5.5开始,源码配置编译工具configure变成了cmake,所以先要去把cmake装上.并安装make,bison,cmake,g ...
- LNMP源码编译安装(centos7+nginx1.9+mysql5.6+php7)
1.准备工作: 1)把所有的软件安装在/Data/apps/,源码包放在/Data/tgz/,数据放在/Data/data,日志文件放在/Data/logs,项目放在/Data/webapps, mk ...
- 【MySQL】源码编译安装和配置MySql 5.5.32(单实例)
[需求描述] 在CentOS环境中,通过编译源码的方式,安装并且配置“单实例”的MySQL5.5.32数据库. MySQL的安装目录为:/application/mysql-5.5.32 MySQL数 ...
- [教程]centos卸载、安装mysql(源码编译安装方式)
-----------1 卸载系统自带的msyql包 rpm -qa|grep mysql rpm -e --nodeps mysql-server-5.1.71-1.el6.x86_64 --强制卸 ...
- centos6 编译安装 mysql5.6----------centos7编译安装MySQL5.7
centos6 编译安装 mysql5.6 安装依赖包 yum install -y ncurses-devel libaio-devel 安装cmake编译工具 cmake 定制功能:存储引擎.字 ...
- CentOS下MySQL 5.7.9编译安装
MySQL 5.7 GA版本的发布,也就是说从现在开始5.7已经可以在生产环境中使用,有任何问题官方都将立刻修复. MySQL 5.7主要特性: 更好的性能:对于多核CPU.固态硬盘.锁有着更好的优化 ...
- Mysql 5.6 Cmake 编译安装
MySQL编译安装 环境: OS: CentOS 6.6x64 mini mysql: mysql-5.6.251. mysql 下载: http://dev.mysql.com/downloads/ ...
- MySQL5.5编译安装以及Debug
MySQL5.5以上版本安装是需要cmake 安装步骤: 设置编译参数cmake -DCMAKE_INSTALL_PREFIX='/data1/guosong/mysql_debug' -DDEF ...
随机推荐
- 【EasyExcel详细步骤】(内附源码)
页面预览 数据导出 数据导入 第01章-Alibaba EasyExcel 1.EasyExcel介绍 1.1.EasyExcel的作用 数据导入:减轻录入工作量 数据导出:统计信息归档 数据传输:异 ...
- [.Net 6]写一个简单的文件上传控件后端
此项目是配合上一篇文章[Vue]写一个简单的文件上传控件 - 林晓lx - 博客园 (cnblogs.com) 的后端程序,使用.Net 6项目框架搭建,开发前请安装Visual Studio 20 ...
- 修改主频 & 时钟树
在system_stm32f10x.c中可以更改这个 最先调用void SystemInit (void)启动HSI+各种恢复缺省配置 然后 调用 SetSysClock();执行设置时钟7 ...
- [转] VSCode中 Vetur插件排版Vue文件 Col 标签子标签不被缩进的问题 iview viewDesign 自动格式化
[转] VSCode中 Vetur插件排版Vue文件 Col 标签子标签不被缩进的问题 iview viewDesign 自动格式化 问题 Col标签不对齐 首先直接放解决办法 在 vsCode se ...
- 创建 nest-websocket 服务 用于mock单点登录开发
需求 有个单点登录的任务,但是都是现场的服务 api 和 websocket 都在现在 开发本机mock服务 本地搭建环境先模拟一下 资料 NestJS WebSocket 开始使用 https:// ...
- CYQ.Data 操作 Redis 性能测试:对比 StackExchange.Redis
前言: 前几天,点开自己的博客,看了一下 CYQ.Data V5系列 都有哪些文章, 发现了一篇2019年写的:CYQ.Data 对于分布式缓存Redis.MemCache高可用的改进及性能测试,于是 ...
- 个性化的单芯片的回声消除(AEC)解决方案
概述 这些年随着智能化产品的广泛应用,各种新型音频产品也层出不穷,在这个古老的领域,传统的回声消除方案一般是功耗高,成本非常高,集成性差.无法满足新产品新市场对回声消除的低成本低功耗个性化需求等特 ...
- Android CheckBox控件去除图标 样式改造
有个UI需要实现下面这种效果,但我之前是使用的CheckBox,本着能改就改的原则,还是把CheckBox改造一份,终于是实现了图中的效果 过程 1.去除CheckBox的左侧图标 CheckBox默 ...
- C++B树的实现
B树的实现 今天我们就来实现以下B树,B树有什么特点那?我们来列举一下 每个非叶子节点中存放若干关键字数据,并且有若干指向儿子节点的指针.指针数目=关键字数目+1 根节点有最少1个,最多m-1个关键字 ...
- 一个简单的RTMP服务器实现 --- RTMP实现要点
PS:要转载请注明出处,本人版权所有. PS: 这个只是基于<我自己>的理解, 如果和你的原则及想法相冲突,请谅解,勿喷. 前置说明 本文作为本人csdn blog的主站的备份.(Bl ...