centos7下安装MySQL 5.7.26 二进制版本(免安装绿色版)
MySQL 5.7.26 二进制版本安装(免安装绿色版)
下载地址
https://downloads.mysql.com/archives/community/
https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

PS:下载一些国外站点软件,用迅雷还是比较管用
下载并上传软件至/opt/software
[root@mysql01 ~]# mkdir -p /opt/software
[root@mysql01 ~]# cd /opt/software/
[root@mysql01 software]# yum install -y lrzsz #文件拖拽软件
[root@mysql01 software]# rz -E
rz waiting to receive.
[root@mysql01 software]# ll
总用量 629756
-rw-r--r-- 1 root root 644869837 4月 18 23:48 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
解压软件
[root@mysql01 software]# tar -xvf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
[root@mysql01 software]# mkdir /application
[root@mysql01 software]# mv mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql
[root@mysql01 software]# cd /application/mysql/
[root@mysql01 mysql]# ls
bin COPYING docs include lib man README share support-files
处理原始环境,删除系统自带mariadb-libs,创建mysql用户
[root@mysql01 ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.64-1.el7.x86_64
[root@mysql01 ~]# yum remove mariadb-libs.x86_64 -y
[root@mysql01 ~]# useradd -s /sbin/nologin mysql
[root@mysql01 ~]# id mysql
uid=1001(mysql) gid=1001(mysql) 组=1001(mysql)
设置环境变量
[root@mysql01 ~]# vim /etc/profile
export PATH=/application/mysql/bin:$PATH
[root@mysql01 ~]# source /etc/profile
查看MySQL版本
[root@mysql01 ~]# mysql -V
mysql Ver 14.14 Distrib 5.7.26, for linux-glibc2.12 (x86_64) using EditLine wrapper
[root@mysql01 ~]# mysql --version
mysql Ver 14.14 Distrib 5.7.26, for linux-glibc2.12 (x86_64) using EditLine wrapper
创建数据路径并授权
1.添加一块新磁盘模拟数据盘
2.格式化并挂载
[root@mysql01 ~]# fdisk -l #查看磁盘、分区信息
[root@mysql01 ~]# mkfs.xfs /dev/sdb
[root@mysql01 ~]# blkid #查看磁盘UUID
/dev/sdb: UUID="5b995ceb-96be-4408-9125-51b931c5c543" TYPE="xfs"
[root@mysql01 ~]# vim /etc/fstab
UUID="5b995ceb-96be-4408-9125-51b931c5c543" /data xfs defaults 0 0
[root@mysql01 ~]# mount -a #是将/etc/fstab的所有内容重新加载
3.对MySQL软件和数据目录进行授权
[root@mysql01 ~]# chown -R mysql.mysql /application/*
[root@mysql01 ~]# chown -R mysql.mysql /data
4.初始化数据(创建系统数据)
# 5.6 版本 初始化命令 /application/mysql/scripts/mysql_install_db
# 5.7 版本
[root@mysql01 ~]# mkdir -p /data/mysql/data #创建初始化数据路径
[root@mysql01 ~]# chown -R mysql.mysql /data
方法一
[root@mysql01 ~]# mysqld --initialize --user=mysql --basedir=/application/mysql --datadir=/data/mysql/data
2020-04-19T14:27:50.401324Z 1 [Note] A temporary password is generated for root@localhost: dr7uTgZ/q!JI
5.7说明:
--initialize 参数:
1. 对于密码复杂度进行定制:12位,4种
2. 密码过期时间:180
3. 给root@localhost用户设置临时密码
方法二
--initialize-insecure 参数:
无限制,无临时密码
[root@mysql01 ~]# rm -rf /data/mysql/data/* #先删除方法一初始化信息
[root@mysql01 ~]# mysqld --initialize-insecure --user=mysql --basedir=/application/mysql --datadir=/data/mysql/data
2020-04-19T15:24:41.446386Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
5.配置文件准备
cat >/etc/my.cnf <<EOF
[mysqld]
user=mysql
basedir=/application/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
server_id=6
port=3306
[mysql]
socket=/tmp/mysql.sock
EOF
6.启动数据库
方法一:
sys-v #centos6中使用
[root@mysql01 ~]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@mysql01 ~]# service mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.Logging to '/data/mysql/data/mysql01.err'.
.. SUCCESS!
[root@mysql01 ~]# netstat -lnp | grep 3306 #通过端口查看是否启动
tcp6 0 0 :::3306 :::* LISTEN 4982/mysqld
方法二:
systemd #centos7中使用
[root@mysql01 ~]# /etc/init.d/mysqld stop #先关闭方法一中启动的MySQL
Shutting down MySQL.. SUCCESS!
[root@mysql01 ~]# cat >/etc/systemd/system/mysqld.service <<EOF
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
EOF
[root@mysql01 ~]# systemctl start mysqld.service
[root@mysql01 ~]# netstat -nlp | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 5134/mysqld
7.如何分析MySQL数据库无法启动情形
查看日志:
在哪?
/data/mysql/data/主机名.err
[ERROR] 上下文
可能情况:
/etc/my.cnf 路径不对等
/tmp/mysql.sock文件修改过 或 删除过
数据目录权限不是mysql
参数改错了
8.修改数据库密码
[root@mysql01 ~]# mysqladmin -uroot -p password
Enter password: #输入旧密码,第一次使用密码为空
New password: #输入新密码
Confirm new password: #再次确认新密码
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
9.管理员用户密码忘记了
--skip-grant-tables #跳过授权表
--skip-networking #跳过远程登录
1)关闭数据库
[root@mysql01 ~]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
2)启动数据库到维护模式
[root@mysql01 ~]# mysqld_safe --skip-grant-tables --skip-networking &
3)登录并修改密码
[root@mysql01 ~]# mysql
mysql> select user,host from mysql.user; #查看用户信息
mysql> select user,host,authentication_string from mysql.user; #查看用户和密码字段信息
mysql> alter user root@'localhost' identified by '123456'; #关闭认证后无法使用这条命令
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges; #手动加载刷新授权表
mysql> alter user root@'localhost' identified by '123456'; #再次执行命令重置密码成功
Query OK, 0 rows affected (0.00 sec)
mysql> exit #退出数据库
Bye
4)停止数据库,再正常启动 登录验证修改密码是否成功
[root@mysql01 ~]# /etc/init.d/mysqld stop
Shutting down MySQL..2020-04-20T15:55:40.277521Z mysqld_safe mysqld from pid file /data/mysql/data/mysql01.pid ended
SUCCESS!
[1]+ 完成 mysqld_safe --skip-grant-tables --skip-networking
[root@mysql01 ~]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@mysql01 ~]# mysql -uroot -p
Enter password: #输入修改后密码验证
centos7下安装MySQL 5.7.26 二进制版本(免安装绿色版)的更多相关文章
- Linux(CentOS 6.5) 下安装MySql 5.7.18 二进制版本粗浅攻略
鉴于Linux和mysql因不同版本,安装方式也不同,所以在阅读本攻略前,请确保各位同学的版本和我的Linux.MySql 版本一致. 如果不一致,只能参考. 我的版本: Linux CentOS 6 ...
- win10环境下MySql(5.7.21版本)安装过程
windows10上安装mysql(详细步骤) 2016年09月06日 08:09:34 阅读数:60405 环境:windwos 10(1511) 64bit.mysql 5.7.14 时间:201 ...
- linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题]
linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题] 一.查看mysql是否已经安装 使用“whereis mysql”命令来查看mysql安装路径: [root@h ...
- MySQL 5.7.18 zip版本的安装使用方法
转自:https://www.cnblogs.com/nepulgh/p/7152618.html MySQL 5.7.18 zip版本的安装使用方法 这个版本的MySQL不像那种点击就可以立即安装, ...
- windows版本免安装redis, nginx, zookeeper
redis官网:https://redis.io/ windows版本免安装redis下载链接:https://github.com/MSOpenTech/redis/releases nginx官网 ...
- Centos7 安装MySQL 5.7 (通用二进制包)
1.下载安装包 下载地址 https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz ...
- CentOS7下一个mysql安装
CentOS7安装MySQL --下载mysql http://mirrors.sohu.com/mysql/MySQL-5.6/ http://mirrors.sohu.com/mysql/MySQ ...
- centos7下使用mysql离线安装包安装mysql5.7
服务器环境: centos7 x64 需要安装mysql5.7+ 一.卸载CentOS7系统自带mariadb # 查看系统自带的Mariadb [root@CDH-141 ~]# rpm -qa|g ...
- CentOS6 下编译安装 MySQL 5.6.26
CentOS6下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.26. 一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | ...
随机推荐
- 兄弟,你爬虫基础这么好,需要研究js逆向了,一起吧(有完整JS代码)
这几天的确有空了,看更新多快,专门研究了一下几个网站登录中密码加密方法,比起滑块验证码来说都相对简单,适合新手js逆向入门,大家可以自己试一下,试不出来了再参考我的js代码.篇幅有限,完整的js代码在 ...
- 从开源协议到谷歌禁用华为、Docker实体清单事件
平时我们在日常开发生活都在大量和开源软件打着交道,例如安卓.Linux.Github.Docker等,而其中开源协议比如MIT.Apache也是耳熟能详,但是真正对开源协议的了解相信对大部分人来说都 ...
- log4j升级到log4j2
log4j升级到log4j2 1.导入依赖 log4j2应尽量使用同一版本,否则可能出现不兼容的情况 <!-- log4j2 start --> <!-- log4j-1.2-api ...
- 焦大:做SEO应该研究的用户需求的方向
http://www.wocaoseo.com/thread-60-1-1.html 最近收到打击很大,收获也颇多,这一切都莫过于用户需求的问题.我曾经给我弟说过,我对检索排名特征识别.提取和计算自认 ...
- Vue最全知识点
声明:本篇文章纯属笔记性文章,非整体原创,是对vue知识的整理, 基础篇 说说你对MVVM的理解 Model-View-ViewModel的缩写,Model代表数据模型,View代表UI组件,View ...
- Clock()函数简单使用(C库函数)
Clock()函数简单使用(转) 存在于标准库<time.h> 描述 C 库函数 clock_t clock(void) 返回程序执行起(一般为程序的开头),处理器时钟所使用的时间.为了获 ...
- Less 预处理笔记
1. less 简介 1. less是CSS的预编译器,可以扩展CSS语言(当然也兼容CSS),可以定义变量.混合.函数等等,让CSS代码更易维护和扩展 2. less与传统写法相比: less后缀为 ...
- 热门话题,2020年了,web前端还好找工作吗?
#大师助手-全网唯一免费上pin 如果你要是和前几年的前端市场相比,那我会告诉你“不好找” 其实好不好找工作,是跟自己的能力分不开的.但是就前端开发这个行业本身来说,它的就业前景还是相当不错的. 随着 ...
- Spring Validation-用注解代替代码参数校验
Spring Validation 概念 在原先的编码中,我们如果要验证前端传递的参数,一般是在接受到传递过来的参数后,手动在代码中做 if-else 判断,这种编码方式会带来大量冗余代码,十分的不优 ...
- 2020重新出发,NOSQL,Redis主从复制
Redis主从复制 尽管 Redis 的性能很好,但是有时候依旧满足不了应用的需要,比如过多的用户进入主页,导致 Redis 被频繁访问,此时就存在大量的读操作. 对于一些热门网站的某个时刻(比如促销 ...