mysql 学习第一天 rpm 通用二进制安装MySQL

rpm 包安装
事先从官网下载 RPM 安装包,上传至服务器:
解压查看:
安装:
首先限制 mariadb 相关软件包。
[root@localhost ~] # ls -l mysql-5.7.14-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 root root 569344000 10 24 2017 mysql-5.7.14-1.el7.x86_64.rpm-
bundle.tar
[root@localhost ~] # tar xf mysql-5.7.14-1.el7.x86_64.rpm-bundle.tar
[root@localhost ~] # ls -l mysql-community*
-rw-r--r-- 1 7155 31415 25012200 7 14 2016 mysql-community-client-5.7.14-
1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 277608 7 14 2016 mysql-community-common-5.7.14-
1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 3770552 7 14 2016 mysql-community-devel-5.7.14-
1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 45366572 7 14 2016 mysql-community-embedded-5.7.14-
1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 23925764 7 14 2016 mysql-community-embedded-compat-
5.7.14-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 125630688 7 14 2016 mysql-community-embedded-devel-
5.7.14-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2235496 7 14 2016 mysql-community-libs-5.7.14-
1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2112812 7 14 2016 mysql-community-libs-compat-
5.7.14-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 51288740 7 14 2016 mysql-community-minimal-debuginfo-
5.7.14-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 158947688 7 14 2016 mysql-community-server-5.7.14-
1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 14021340 7 14 2016 mysql-community-server-minimal-
5.7.14-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 116741256 7 14 2016 mysql-community-test-5.7.14-
1.el7.x86_64.rpm
其中:
mysql-community-client 客户端
mysql-community-devel 开发库
mysql-community-common 服务端和客户端的公共文件
mysql-community-embedded 嵌入式
mysql-community-serve 服务端
mysql-community-test 测试组件
mysql-community-libs 共享库
mysql-community-libs-compat MySQL 之前版本的共享兼容库
[root@localhost ~] # yum remove mariadb-libs
安装:
[root@localhost ~] # rpm -ivh mysql-community-client-5.7.14-1.el7.x86_64.rpm
mysql-community-common-5.7.14-1.el7.x86_64.rpm mysql-community-libs-5.7.14-
1.el7.x86_64.rpm mysql-community-server-5.7.14-1.el7.x86_64.rpm 启动:
2.2 通用二进制格式安装
1 、下载 glibc 版本的 Mysql
2 、新建用户以安全方式运行进程
3 、安装并初始化 mysql
初始化
4 、为 mysql 提供主配置文件
5 、为 mysql 提供 sysv 服务脚本
6 、启动 mysql
[root@localhost ~] # systemctl start mysqld
[root@localhost ~] # systemctl enable mysqld
mysql-5.7.14-linux-glibc2.5-x86_64.tar
groupadd -r -g 306 mysql
useradd -g 306 -r -u 306 mysql
[root@localhost ~] # tar xf mysql-5.7.14-linux-glibc2.5-x86_64.tar -C /usr/local/
[root@localhost ~] # cd /usr/local/
[root@localhost local] # tar xf mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz
[root@localhost local] # ln -sv mysql-5.7.14-linux-glibc2.5-x86_64 mysql
"mysql" - > "mysql-5.7.14-linux-glibc2.5-x86_64"
[root@localhost local] # chown -R mysql.mysql mysql/*
mysql/bin/mysqld --initialize --user = mysql --basedir = /usr/local/mysql --
datadir = /usr/local/mysql/data
注意记录临时密码:
2019 -09-30T07 :54:09.437644Z 1 [Note] A temporary password is generated for
root@localhost: Di23xhiKVt-W
[root@localhost local] # cd /usr/local/mysql
[root@localhost mysql] # \cp support-files/my-default.cnf /etc/my.cnf
vim /etc/my.cnf
添加如下行指定 mysql 数据文件的存放位置:
datadir = /usr/local/mysql/data
[root@localhost mysql] # cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql] # chmod +x /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld -- 添加为系统服务
# chkconfig mysqld on -- 开机自启动
systemctl start mysqld 7 、将 mysql bin 目录加入 PATH 环境变量,编辑 /etc/profile 文件
使用 mysql 客户端命令
由于 PATH 环境变量中没有添加,因此有两种方式:
一种是用绝对路径,如下:
第一种用起来比较麻烦,我们下面用第二种添加到 PATH
2.3 源码安装
5.5 开始使用 cmake 编译。
1 、安装开发工具和开发包
2 、编译安装 MySQL
1 )解压
2 )使用 cmake 编译 MySQL
cmake 指定编译选项的方式不同于 make ,其实现方式对比如下:
./configure cmake .
./configure --help cmake . -LH or ccmake .
注意:如果想清理此前的编译所生成的文件重新编译,则需要使用如下两条命令:
make clean rm CMakeCache.txt
创建用户和组
[root@localhost mysql] # mysql
-bash : mysql: 未找到命令
/usr/local/mysql/bin/mysql
# cd /etc/profile.d/
# vim mysql.sh
添加如下内容
export PATH = $PATH :/usr/local/mysq
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值