当前位置:网站首页>CentOS7部署MySQL数据库服务器
CentOS7部署MySQL数据库服务器
2022-07-28 05:28:00 【【异度空间】】
CentOS7部署MySQL数据库服务器
环境准备
- 主机
| 主机名 | IP地址1(外网) | IP地址2(内网) | 系统 | 其他 |
|---|---|---|---|---|
| mysql-server | 192.168.72.130 | 202.207.240.130 | CetOS7.5.1804 | MEM:2G ;CPU:2P/2C;DISK:15G |
- 关闭防火墙等安全组件
- 配置CentOS-Base源
- 配置mysql安装源(yum安装方式需要)
说明:本文实验采用yum方式和二进制安装方式来进行安装MySQL,其中MySQL的版本为5.xx
YUM安装
mkdir -p /server/tools
wget -O /server/tools/mysql-community-release-el7-5.noarch.rpm http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh /server/tools/mysql-community-release-el7-5.noarch.rpm
卸载默认的mariadb
rpm -aq mariadb* rpm -e --nodeps mariadb-libs安装mysql
yum install mysql mysql-server -y启动mysql服务
systemctl start mysqld systemctl enable mysqld输入命令
mysql验证mysql是否安装成功

设置mysql数据库密码
mysqladmin -uroot password 'xxxxxx'
二进制安装
下载二进制mysql软件包
下载地址:https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
建议提前下载在上传到指定目录,包比较大在线下载较慢
mkdir -p /server/tools
cd /server/tools
wget https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
cd /server/tools
tar xzvf mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
mkdir -p /application
mv mysql-5.7.35-linux-glibc2.12-x86_64 /application/mysql-5.7.35
ln -s /application/mysql-5.7.35 /application/mysql
rpm -aq mariadb*
rpm -e --nodeps mariadb-libs
yum install libaio-devel -y
useradd mysql -s /sbin/nologin -M
mkdir -p /application/mysql/data
chown -R mysql:mysql /application/mysql
cat >/etc/my.cnf <<EOF [mysqld] basedir = /application/mysql datadir = /application/mysql/data socket = /tmp/mysql.sock server_id = 1 port = 3306 log_error = /application/mysql/data/error_mysql.err [mysql] socket = /tmp/mysql.sock prompt = wjz [\\d]> EOF
/application/mysql/bin/mysqld --initialize-insecure --user=mysql \
--basedir=/application/mysql/ --datadir=/application/mysql/data
cat >/usr/lib/systemd/system/mysql.service <<EOF [Unit] Description=MySQL5.7.35 database server After=syslog.target After=network.target [Service] User=mysql Group=mysql ExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/my.cnf LimitNOFILE = 5000 [Install] WantedBy=multi-user.target EOF
编写后,可以启动mysql进行测试
systemctl start mysql
systemctl enable mysql
systemctl status mysql

echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
source /etc/profile

mysqladmin -uroot password 'xxxxxx'

边栏推荐
- Valgrind tool
- 数组转链表
- archery数据库审核平台部署
- 技术分享 | 服务端接口自动化测试, Requests 库的这些功能你了解吗?
- Project compilation nosuch*** error problem
- Mysql-8.0.17-winx64 (additional Navicat) manual configuration version installation
- Question brushing record - linked list
- Question brushing record ---- reverse the linked list (reverse the whole linked list)
- RayMarching实现体积光渲染
- [pta ---- traversal of tree]
猜你喜欢

mysql索引优化

Bug experience related to IAP jump of stm32

Two dimensional array practice: spiral matrix
![[hash table basics]](/img/8f/54a4780a02f81e5de3d92c25248e1e.png)
[hash table basics]

关于Shader KeyWord的整理

archery数据库审核平台部署
![[C language] string library function introduction and simulation](/img/83/b23fdcbbbd792029083b310c89d4bc.png)
[C language] string library function introduction and simulation

SSAO By Computer Shader(一)

Leetcode brush question diary sword finger offer II 053. Medium order successor in binary search tree

RayMarching realizes volume light rendering
随机推荐
遍历 二叉树
Explain in detail
[dynamic planning -- the best period for buying and selling stocks Series 2]
Initializingbean interface and examples
feignclient @RequestMapping参数设置及请求头简易方式设置
什么是线性表?
NIO示例
关于Shader KeyWord的整理
OJ 1242 freshman's debut
Network communication and tcp/ip protocol
About the collation of shader keyword
PKU-2524-Ubiquitous Religions(并查集模板)
OJ 1045 reverse and add
Leetcode brush questions diary sword finger offer II 047. Binary tree pruning
ZOJ Problem 1005 jugs
软件测试(概念篇)
技术分享 | 使用postman发送请求
水渲染示例
下雨场景效果(一)
Yapi vulnerability hanging horse program chongfu.sh processing