Linux7.6二进制安装Mysql8.0.27详细操作步骤
来源:脚本之家
2022-12-30 09:40:17
0浏览
收藏
亲爱的编程学习爱好者,如果你点开了这篇文章,说明你对《Linux7.6二进制安装Mysql8.0.27详细操作步骤》很感兴趣。本篇文章就来给大家详细解析一下,主要介绍一下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 [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 <p style="text-align: center;"><img src="/uploads/20221230/167236473963ae42c376a4b.png" alt="在这里插入图片描述"></p> <h2>六.创建参数文件</h2> <pre class="brush:bash;"> 由于是二进制文件安装,数据库参数文件需要自己配置 cat >> /mysql/conf/my3306.cnf <h2>七.数据库初始化</h2> <pre class="brush:bash;"> 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详细操作步骤》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于mysql的知识点!
版本声明
本文转载于:脚本之家 如有侵犯,请联系study_golang@163.com删除

- 上一篇
- VS2019连接MySQL数据库的过程及常见问题总结

- 下一篇
- mysql 事务解析
评论列表
-
- 爱笑的大树
- 很棒,一直没懂这个问题,但其实工作中常常有遇到...不过今天到这,帮助很大,总算是懂了,感谢作者大大分享博文!
- 2023-02-07 19:48:38
-
- 文静的电话
- 这篇技术文章真及时,太全面了,很好,码起来,关注作者了!希望作者能多写数据库相关的文章。
- 2023-02-02 03:23:34
查看更多
最新文章
-
- 数据库 · MySQL | 1天前 |
- MySQL设置中文界面,超简单教程来了!
- 332浏览 收藏
-
- 数据库 · MySQL | 1天前 | mysql 索引提示
- MySQL进阶必看!FORCE/USE/IGNOREINDEX用法大揭秘
- 182浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- 手把手教你写MySQL存储过程,小白也能轻松上手
- 163浏览 收藏
-
- 数据库 · MySQL | 1天前 | mysql group by
- MySQL分组查询优化:GROUPBY原理+索引优化超全解析
- 324浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- MySQL设置中文语言,轻松拥有中文界面
- 211浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- MySQL建库语句从入门到精通:创建数据库+设置字符集&排序规则(附实例)
- 176浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- 从零开始学MySQL数据库操作,小白轻松变大神!
- 496浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- MySQL插入日期到时间字段,轻松搞定日期格式
- 484浏览 收藏
-
- 数据库 · MySQL | 1天前 | mysql 数据压缩
- MySQL怎么实现高效压缩存储?表压缩+列式存储详细解读
- 272浏览 收藏
-
- 数据库 · MySQL | 1天前 | mysql JOIN优化
- MySQL优化JOIN操作:七大技巧教你提升关联查询速度
- 106浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- MySQL出现中文乱码?超详细解决方案一次性搞定
- 211浏览 收藏
-
- 数据库 · MySQL | 1天前 |
- MySQL主从复制这样配!搞懂这些参数,replication稳了~
- 131浏览 收藏
查看更多
课程推荐
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 542次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 508次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 497次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 484次学习
查看更多
AI推荐
-
- 茅茅虫AIGC检测
- 茅茅虫AIGC检测,湖南茅茅虫科技有限公司倾力打造,运用NLP技术精准识别AI生成文本,提供论文、专著等学术文本的AIGC检测服务。支持多种格式,生成可视化报告,保障您的学术诚信和内容质量。
- 18次使用
-
- 赛林匹克平台(Challympics)
- 探索赛林匹克平台Challympics,一个聚焦人工智能、算力算法、量子计算等前沿技术的赛事聚合平台。连接产学研用,助力科技创新与产业升级。
- 50次使用
-
- 笔格AIPPT
- SEO 笔格AIPPT是135编辑器推出的AI智能PPT制作平台,依托DeepSeek大模型,实现智能大纲生成、一键PPT生成、AI文字优化、图像生成等功能。免费试用,提升PPT制作效率,适用于商务演示、教育培训等多种场景。
- 57次使用
-
- 稿定PPT
- 告别PPT制作难题!稿定PPT提供海量模板、AI智能生成、在线协作,助您轻松制作专业演示文稿。职场办公、教育学习、企业服务全覆盖,降本增效,释放创意!
- 53次使用
-
- Suno苏诺中文版
- 探索Suno苏诺中文版,一款颠覆传统音乐创作的AI平台。无需专业技能,轻松创作个性化音乐。智能词曲生成、风格迁移、海量音效,释放您的音乐灵感!
- 57次使用
查看更多
相关文章
-
- Mysql服务器的安装配置与启动关闭方法详解
- 2022-12-31 224浏览
-
- MySQL安装常见报错处理方法总结大全
- 2022-12-30 296浏览
-
- MySQL安装失败的原因及解决步骤
- 2022-12-28 346浏览
-
- MySQL8.0.27安装过程中卡在Initializing Database中并报错的解决
- 2022-12-30 283浏览
-
- Windows下MySQL详细安装过程及基本使用
- 2023-01-01 373浏览