Linux7.6二进制安装Mysql8.0.27详细操作步骤

目录
  • 一、环境准备
    • 1.1 操作系统版本
    • 1.2 磁盘空间
    • 1.3 关闭防火墙
    • 1.4 关闭 selinux
    • 1.5 HOST解析
    • 1.6 Mysql下载
  • 二、 yum安装及配置
    • 2.1 挂载本地光盘镜像
    • 2.2 配置yum源
    • 2.3 安装依赖包
  • 三、卸载MariaDB
  • 四、安装 MySQL
    • 4.1 用户及目录创建
    • 4.2 用户及组
    • 4.3 上传软件包并解压
  • 五.环境变量配置
  • 六.创建参数文件
  • 七.数据库初始化
  • 八.启动Mysql
  • 九.登陆Mysql
  • 十.修改密码
  • 十一.远程登陆设置

一、环境准备

1.1 操作系统版本

[root@rhel76 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)

1.2 磁盘空间

[root@rhel76 ~]# df -TH
Filesystem            Type      Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs        32G  4.6G   27G  15% /
devtmpfs              devtmpfs  2.1G     0  2.1G   0% /dev
tmpfs                 tmpfs     2.1G     0  2.1G   0% /dev/shm
tmpfs                 tmpfs     2.1G   14M  2.1G   1% /run
tmpfs                 tmpfs     2.1G     0  2.1G   0% /sys/fs/cgroup
/dev/sda1             xfs       996M  172M  825M  18% /boot
/dev/mapper/rhel-u01  xfs        30G   34M   30G   1% /u01
tmpfs                 tmpfs     413M  4.1k  413M   1% /run/user/42
tmpfs                 tmpfs     413M   46k  413M   1% /run/user/0

1.3 关闭防火墙

[root@rhel76 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-11-23 23:46:04 UTC; 9min ago
     Docs: man:firewalld(1)
Main PID: 9621 (firewalld)
    Tasks: 2
   CGroup: /system.slice/firewalld.service
           └─9621 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Nov 23 23:46:03 rhel76 systemd[1]: Starting firewalld - dynamic firewall daemon...
Nov 23 23:46:04 rhel76 systemd[1]: Started firewalld - dynamic firewall daemon.

[root@rhel76 ~]# systemctl stop firewalld
[root@rhel76 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

1.4 关闭 selinux

[root@rhel76 ~]# getenforce
Enforcing

[root@rhel76 ~]# cp /etc/selinux/config /etc/selinux/config_`date +"%Y%m%d_%H%M%S"`
[root@rhel76 ~]# sed -i 's/SELINUX\=enforcing/SELINUX\=disabled/g' /etc/selinux/config

以上修改完后重启
[root@rhel76 ~]# reboot

[root@rhel76 ~]# getenforce
Disabled
[root@rhel76 ~]# sestatus
SELinux status:  disabled

1.5 HOST解析

[root@rhel76 ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.6.81 rhel76

[root@rhel76 ~]# hostname
rhel76

1.6 Mysql下载

https://dev.mysql.com/downloads/mysql/
MD5: 0bdd171cb8464ba32f65f7bf58bc9533

二、 yum安装及配置

2.1 挂载本地光盘镜像

[root@rhel76 ~]# mkdir -p /mnt/dvd/

[root@rhel76 ~]# df -TH
Filesystem            Type      Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs        32G  4.7G   27G  15% /
devtmpfs              devtmpfs  2.1G     0  2.1G   0% /dev
tmpfs                 tmpfs     2.1G     0  2.1G   0% /dev/shm
tmpfs                 tmpfs     2.1G   14M  2.1G   1% /run
tmpfs                 tmpfs     2.1G     0  2.1G   0% /sys/fs/cgroup
/dev/sda1             xfs       996M  172M  825M  18% /boot
/dev/mapper/rhel-u01  xfs        30G   34M   30G   1% /u01
tmpfs                 tmpfs     413M   21k  413M   1% /run/user/0
tmpfs                 tmpfs     413M   13k  413M   1% /run/user/42
/dev/sr0              iso9660   4.5G  4.5G     0 100% /run/media/root/RHEL-7.6 Server.x86_64

[root@rhel76 ~]# mount /dev/sr0 /mnt/dvd
mount: /dev/sr0 is write-protected, mounting read-only
You have mail in /var/spool/mail/root

2.2 配置yum源

[root@rhel76 ~]# cd /etc/yum.repos.d/
[root@rhel76 yum.repos.d]# cat >> /etc/yum.repos.d/redhat.repo << "EOF"
> [rhel7]
> name=jeames repo
> baseurl=file:///mnt/dvd/
> gpgcheck=0
> EOF

2.3 安装依赖包

[root@rhel76 ~]# yum -y groupinstall "DeveLopment tools"
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
Warning: Group development does not have any packages to install.
Maybe run: yum groups mark install (see man yum)
No packages in any requested group available to install or update

[root@rhel76 ~]# yum -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make

三、卸载MariaDB

[root@rhel76 ~]# rpm -qa |grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64

[root@rhel76 ~]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

四、安装 MySQL

4.1 用户及目录创建

注:可以部署多个实例,通过端口区分root 用户操作:mkdir -p /mysql/data/mysql3306mkdir -p /mysql/app/mkdir -p /mysql/conf/mkdir -p /mysql/data/mysql3306/pid/mkdir -p /mysql/data/mysql3306/socket/mkdir -p /mysql/data/mysql3306/log/mkdir -p /mysql/data/mysql3306/binlog/mkdir -p /mysql/data/mysql3306/errlogmkdir -p /mysql/data/mysql3306/relaylog/mkdir -p /mysql/data/mysql3306/slowlog/mkdir -p /mysql/data/mysql3306/tmp/

4.2 用户及组

[root@rhel76 ~]# groupadd mysql
[root@rhel76 ~]# useradd -g mysql mysql
[root@rhel76 ~]# chown -R mysql:mysql /mysql
[root@rhel76 ~]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.

[root@rhel76 ~]# cat /etc/group | grep mysql
mysql:x:1001:
[root@rhel76 ~]# cat /etc/passwd | grep mysql
mysql:x:1001:1001::/home/mysql:/bin/bash

4.3 上传软件包并解压

[root@rhel76 ~]# cp mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz /mysql/app
[root@rhel76 ~]# chown -R mysql:mysql /mysql

mysql用户操作
[root@rhel76 ~]# su - mysql
md5 值验证,保证下载到的软件包无破损无木马
[mysql@rhel76 ~]$ cd /mysql/app
[mysql@rhel76 app]$ ll
total 1168588
-rw-r--r-- 1 mysql mysql 1196633756 Nov 24 00:49 mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
[mysql@rhel76 app]$ md5sum mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
0bdd171cb8464ba32f65f7bf58bc9533  mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz

解压软件包并重命名
[mysql@rhel76 app]$ tar xvf mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
[mysql@rhel76 app]$ mv mysql-8.0.27-linux-glibc2.12-x86_64 mysql8.0.27

[mysql@rhel76 app]$ ll
total 1168588
drwxrwxr-x 9 mysql mysql        129 Nov 24 00:54 mysql8.0.27
-rw-r--r-- 1 mysql mysql 1196633756 Nov 24 00:49 mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz

五.环境变量配置

cat >> /home/mysql/.bash_profile << "EOF"
MYSQL_HOME=/mysql/app/mysql8.0.27
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$MYSQL_HOME/bin
EOF

source ~/.bash_profile
which mysql

六.创建参数文件

由于是二进制文件安装,数据库参数文件需要自己配置

cat >> /mysql/conf/my3306.cnf << "EOF"
[mysqld]
server_id = 80273306
default-storage-engine= InnoDB
basedir=/mysql/app/mysql8.0.27
datadir=/mysql/data/mysql3306/data/
socket=/mysql/data/mysql3306/socket/mysql.sock
log-error=/mysql/data/mysql3306/log/mysqld.log
pid-file=/mysql/data/mysql3306/pid/mysqld.pid
port=3306
default-time_zone='+8:00'
default_authentication_plugin=mysql_native_password # 加此参数可远程登陆
transaction_isolation=READ-COMMITTED
max_connections=1500
back_log=500
wait_timeout=1800
max_user_connections=800
innodb_buffer_pool_size=1024M
innodb_log_file_size=512M
innodb_log_buffer_size=40M
slow_query_log=ON
long_query_time=5
# log settings #
slow_query_log = ON
slow_query_log_file = /mysql/data/mysql3306/slowlog/slow3306.log
log_error = /mysql/data/mysql3306/errlog/err3306.log
log_error_verbosity = 3
log_bin = /mysql/data/mysql3306/binlog/mysql_bin
log_bin_index = /mysql/data/mysql3306/binlog/mysql_binlog.index
general_log_file = /data/mysql/mysql3306/generallog/general.log
log_queries_not_using_indexes = 1
log_slow_admin_statements = 1
expire_logs_days = 90
binlog_expire_logs_seconds = 2592000      #30d
long_query_time = 2
min_examined_row_limit = 100
log_throttle_queries_not_using_indexes = 1000
innodb_flush_log_at_trx_commit=1

EOF

七.数据库初始化

mysql用户操作:
mysqld --defaults-file=/mysql/conf/my3306.cnf --initialize --user=mysql --basedir=/mysql/app/mysql8.0.27 --datadir=/mysql/data/mysql3306/data/
注意:以上同一行执行

八.启动Mysql

[mysql@rhel76 ~]$ mysqld_safe --defaults-file=/mysql/conf/my3306.cnf --user=mysql &
[1] 21406
[mysql@rhel76 ~]$ 2021-11-24T06:14:23.240372Z mysqld_safe Logging to '/mysql/data/mysql3306/errlog/err3306.log'.
2021-11-24T06:14:23.296992Z mysqld_safe Starting mysqld daemon with databases from /mysql/data/mysql3306/data

九.登陆Mysql

第一次登录 MySQL 时,需要到错误日志下找初始化密码,我这里的密码为:-(Qy5Aj9t,=a
使用 socket 加密码登录进去后,无法查询任何东西,提示先要修改 root 密码。

[mysql@rhel76 ~]$ cat /mysql/data/mysql3306/errlog/err3306.log | grep password

2021-11-24T06:12:14.610657Z 0 [Note] [MY-010309] [Server] Auto generated RSA key files through --sha256_password_auto_generate_rsa_keys are placed in data directory.
2021-11-24T06:12:14.610686Z 0 [Note] [MY-010308] [Server] Skipping generation of RSA key pair through --caching_sha2_password_auto_generate_rsa_keys as key files are present in data directory.
2021-11-24T06:12:14.615367Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: -(Qy5Aj9t,=a
2021-11-24T06:14:26.153958Z 0 [Note] [MY-010308] [Server] Skipping generation of RSA key pair through --sha256_password_auto_generate_rsa_keys as key files are present in data directory.
2021-11-24T06:14:26.153979Z 0 [Note] [MY-010308] [Server] Skipping generation of RSA key pair through --caching_sha2_password_auto_generate_rsa_keys as key files are present in data directory.

[mysql@rhel76 ~]$ mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

##此处通过sock登陆
[mysql@rhel76 ~]$ mysql -uroot -p  -P 3306 -S /mysql/data/mysql3306/socket/mysql.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> status
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

十.修改密码

mysql> alter user root@'localhost' identified by 'root';Query OK, 0 rows affected (0.01 sec)mysql> status--------------mysql  Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL)Connection id:          8Current database:Current user:           root@localhostSSL:                    Not in useCurrent pager:          stdoutUsing outfile:          ''Using delimiter:        ;Server version:         8.0.27Protocol version:       10Connection:             Localhost via UNIX socketServer characterset:    utf8mb4Db     characterset:    utf8mb4Client characterset:    utf8mb4Conn.  characterset:    utf8mb4UNIX socket:            /mysql/data/mysql3306/socket/mysql.sockBinary data as:         HexadecimalUptime:                 8 min 0 secThreads: 2  Questions: 7  Slow queries: 0  Opens: 398  Flush tables: 3  Open tables: 36  Queries per second avg: 0.014--------------

十一.远程登陆设置

使用如下语句创建 root 用户是无法通过 navicat 等客户端登录的,
由于从 MySQL8 开始,身份验证插件发生改变,
默认的 “caching_sha2_password” 不允许远程登录,
故需将此插件修改为 “mysql_native_password” 便可登录。

mysql> create user root@'%' identified with mysql_native_password by 'root';
mysql> grant all on *.* to root@'%' with grant option;
mysql> flush privileges;

mysql> select user,host,plugin from mysql.user;
+------------------+-----------+-----------------------+
| user             | host      | plugin                |
+------------------+-----------+-----------------------+
| root             | %         | mysql_native_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session    | localhost | caching_sha2_password |
| mysql.sys        | localhost | caching_sha2_password |
| root             | localhost | mysql_native_password |
+------------------+-----------+-----------------------+
5 rows in set (0.00 sec)

到此这篇关于Linux7.6二进制安装Mysql8.0.27详细操作步骤的文章就介绍到这了,更多相关Linux7.6二进制安装Mysql8.0.27内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • Linux下MySQL5.7.18二进制包安装教程(无默认配置文件my_default.cnf)

    最新在学习MySQL,纯新手,对Linux了解的也不多,因为是下载的最新版的MySQL(MySQL5.7.18)二进制包,CentOS7.2下测试安装,方便以后折腾. 大概步骤如下,安装删除反复折腾了几遍,按照以下步骤,应该没啥问题了. 也没有想象中的复杂,大部分步骤都是参考网上的,照做就是了,出错的话,多尝试,多查资料. 操作系统版本 创建mysql组和用户 下载最新版的MySQL 5.7.18二进制包,上传至服务器的usr/local目录下 解压MySQL二进制包 如下是解压之后的,并且重命

  • Linux下Mysql5.6 二进制安装过程

    1.1下载二进制安装包 wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz 1.2创建 mysql用户与组 groupadd -r -g 306 mysql useradd -r -g 306 -u 306 -m -s /sbin/nologin mysql 1.3解压 tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar

  • Linux下mysql5.6.24(二进制)自动安装脚本

    本文为大家分享了Linux环境下mysql5.6.24自动安装脚本代码,供大家参考,具体内容如下 说明: 一.本脚本仅供测试使用,若正式环境想要使用,需更改脚本的一些参数. 二.使用本脚本之前,需保证linux环境可以联网下载,若不能联网,则需要将下载好的mysql二进制包上传至linux中的/data目录下. 三.脚本使用是需一次输入三个参数: 1.需安装的mysql版本号,如:5.6.24 2.需安装的mysql端口设置,如:3306 3.mysql的server_id设置,如:100330

  • Linux7.6二进制安装Mysql8.0.27详细操作步骤

    目录 一.环境准备 1.1 操作系统版本 1.2 磁盘空间 1.3 关闭防火墙 1.4 关闭 selinux 1.5 HOST解析 1.6 Mysql下载 二. yum安装及配置 2.1 挂载本地光盘镜像 2.2 配置yum源 2.3 安装依赖包 三.卸载MariaDB 四.安装 MySQL 4.1 用户及目录创建 4.2 用户及组 4.3 上传软件包并解压 五.环境变量配置 六.创建参数文件 七.数据库初始化 八.启动Mysql 九.登陆Mysql 十.修改密码 十一.远程登陆设置 一.环境准

  • 阿里云centos7中安装MySQL8.0.13的方法步骤

    1.下载MySQL安装包 (这里是有技巧的,说不定我这时写这个的时候版本还是你看到时的旧版本了,如果已经不是8.0了,可以根据这样来 下新版本) 先进入官网 再将这两者一结合,就是最新版本的了 所以 [root@h1 ~]# rpm -ivh http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm 2.安装mysql [root@localhost ~]# yum install -y mysql-server 或

  • M1芯片安装mysql8.0数据库的实现步骤(图文)

    一.下载 首先给大家推荐一个mysql的国内镜像,虽然不是特别快,但对比起官方网站,还是快了不少,同时资源内容也有保证,不会下载到其他乱七八糟的东西 地址:http://mirrors.sohu.com/mysql/ 选择你需要的版本下载就可以了 注:可以用command+f搜索(图为5.7)本次安装8.0 二.安装 无脑继续就可以了 这里选择第三个,点next并设置mysql密码 勾选下面表示安装完成后启动mysql服务 配置环境变量 打开终端切换至根目录 编辑.bash_profile cd

  • Ubuntu上Vim安装NERDTree插件的详细操作步骤

    NERDTree是Vim的文件系统浏览器,使用此插件,用户可以直观地浏览复杂的目录层次结构,快速打开文件以进行读取或编辑,以及执行基本的文件系统操作.NERDTree源码在https://github.com/preservim/nerdtree . 这里通过Vundle安装NERDTree,Vundle是Vim软件包的缩写,是Vim插件管理器.Vundle源码在https://github.com/VundleVim/Vundle.vim . 安装Vundle: (1). 执行如下命令: mk

  • Redhat7.3安装MySQL8.0.22的详细教程(二进制安装)

    一.MySQL安装包下载 官网地址:https://dev.mysql.com/downloads/mysql/ 下载步骤: 过滤操作系统版本 选择归档安装包 下载后,上传并md5校验安装包是否与上图官方提供的值一致,确保传输过程安装包无损害 [root@MyDB1 ~]# cd /usr/local/software/ [root@MyDB1 software]# md5sum mysql-8.0.22-el7-x86_64.tar.gz 52e312605f66aaaa0efcd272b9f

  • CentOS7版本安装Mysql8.0.20版本数据库的详细教程

    相关阅读: MySQL8.0.20安装教程及其安装问题详细教程  https://www.jb51.net/article/186202.htm mysql8.0.20下载安装及遇到的问题(图文详解)  https://www.jb51.net/article/186208.htm CentOS7安装Mysql8.0.20步骤: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-20.html 官网下载有时速度比较慢,直接点击链接也

  • 阿里云centos7安装mysql8.0.22的详细教程

    1. 下载MySQL安装包 首先点击https://dev.mysql.com/downloads/repo/yum/ 找到Linux7的版本: 这里会自动下载最新的版本的mysql,我这里是mysql8.0.22 然后去拼接网址: http://dev.mysql.com/get/ + xxx.rpm 比如说我的是http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm 所以命令: [root@hadoop ~]#

  • CentOS 7.4 64位安装配置MySQL8.0的详细步骤

    第一步:获取mysql YUM源 进入mysql官网获取RPM包下载地址 https://dev.mysql.com/downloads/repo/yum/ 点击下载 获取到下载链接: https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm -------------------------------------------------------------------------------- 第二步:下载和安装

  • 源码编译安装MySQL8.0.20的详细教程

    在上篇文章给大家介绍了: MySQL8.0.20安装教程及其安装问题详细教程  https://www.jb51.net/article/186202.htm mysql8.0.20下载安装及遇到的问题(图文详解)  https://www.jb51.net/article/186208.htm CentOS7安装Mysql8.0.20步骤: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-20.html 1 概述 本文章主要讲述

  • MySQL8.0.27安装过程中卡在Initializing Database中并报错的解决

    目录 报错信息如下: 解决方案: 附:清理注册表的方法 本文主要介绍了MySQL8.0.27安装过程中卡在Initializing Database中并报错的解决,具有一定的参考价值,具体如下: 报错信息如下: Beginning configuration step: Initializing database (may take a long time)Attempting to run MySQL Server with --initialize-insecure option…Start

随机推荐