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 二进制版本(免安装绿色版)的更多相关文章

  1. Linux(CentOS 6.5) 下安装MySql 5.7.18 二进制版本粗浅攻略

    鉴于Linux和mysql因不同版本,安装方式也不同,所以在阅读本攻略前,请确保各位同学的版本和我的Linux.MySql 版本一致. 如果不一致,只能参考. 我的版本: Linux CentOS 6 ...

  2. win10环境下MySql(5.7.21版本)安装过程

    windows10上安装mysql(详细步骤) 2016年09月06日 08:09:34 阅读数:60405 环境:windwos 10(1511) 64bit.mysql 5.7.14 时间:201 ...

  3. linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题]

    linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题] 一.查看mysql是否已经安装 使用“whereis mysql”命令来查看mysql安装路径: [root@h ...

  4. MySQL 5.7.18 zip版本的安装使用方法

    转自:https://www.cnblogs.com/nepulgh/p/7152618.html MySQL 5.7.18 zip版本的安装使用方法 这个版本的MySQL不像那种点击就可以立即安装, ...

  5. windows版本免安装redis, nginx, zookeeper

    redis官网:https://redis.io/ windows版本免安装redis下载链接:https://github.com/MSOpenTech/redis/releases nginx官网 ...

  6. 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 ...

  7. CentOS7下一个mysql安装

    CentOS7安装MySQL --下载mysql http://mirrors.sohu.com/mysql/MySQL-5.6/ http://mirrors.sohu.com/mysql/MySQ ...

  8. centos7下使用mysql离线安装包安装mysql5.7

    服务器环境: centos7 x64 需要安装mysql5.7+ 一.卸载CentOS7系统自带mariadb # 查看系统自带的Mariadb [root@CDH-141 ~]# rpm -qa|g ...

  9. CentOS6 下编译安装 MySQL 5.6.26

    CentOS6下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.26. 一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | ...

随机推荐

  1. Public-Key Cryptosystems Based on Composite Degree Residuosity Classes

    郑重声明:原文参见标题,如有侵权,请联系作者,将会撤销发布! 以下是对本文关键部分的摘抄翻译,详情请参见原文. 论文未全部翻译 Abstract. 本文研究了一个新的计算问题,即合数剩余阶问题(Com ...

  2. OMG,12 个精致的 Java 字符串操作小技巧,学它

    字符串可以说是 Java 中最具有代表性的类了,似乎没有之一哈,这就好像直播界的李佳琪,脱口秀中的李诞,一等一的大哥地位.不得不承认,最近吐槽大会刷多了,脑子里全是那些段子,写文章都有点不由自主,真的 ...

  3. 【原创】Kuberneters-ConfigMap的实践

    一.什么是ConfigMap        ConfigMap翻译过来即为“配置字典”,在实际的生产环境中,应用程序配置经常需要且又较为复杂,参数.config文件.变量等如果直接打包到镜像中,将会降 ...

  4. 基于postman的api自动化测试实践

    测试的好处 每个人都同意测试很重要,但并不是所有人都会去做.每当你添加新的代码,测试可以保证你的api按照预期运行.通过postman,你可以为所有api编写和运行测试脚本. postman中的测试 ...

  5. asterisk PBX 对接中国移动IMS

    前提: 最近有项目需求,需要对接移动的IMS,移动的对接同事给出了信息: 用户名:+86750735xxxx@ims.gd.chinamobile.com  密码:123456 (系统导入的号码,默认 ...

  6. windows版redis报错:本地计算机上的Redis服务启动后停止

    解决 1.如果需要临时启动Redis 使用命令:redis-server.exe   redis.windows.conf   --maxheap 200m 说明:200m是指定最大堆内存是200m, ...

  7. JS开发必须知道的41个技巧

    JS是前端的核心,但有些使用技巧你还不一定知道:本文梳理了JS的41个技巧,帮助大家提高JS的使用技巧: Array 1.数组交集 普通数组 const arr1 = [, , , , , ,],ar ...

  8. Selenium学习整理(Python)

    1 准备软件 Selenium IDE firebug-2.0.19.xpi firepath-0.9.7-fx.xpi Firefox_46.0.1.5966_setup.exe 由于火狐浏览器高版 ...

  9. Codeforces1409 题解(A-F)

    A. Yet Another Two Integers Problem 最优的操作中,\(k = \min(10, abs(a - b))\),记\(d=abs(a-b)\),最终的答案为\(ans ...

  10. 在logback的fileNamePattern配置%i 带来的异常

    我在logback的配置文件中企图这样配置: <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPol ...