实战:通用二进制格式安装 MySQL(mysql-5.7.29)-2024.4.6(测试成功)

news/2024/10/21 10:01:17/

image-20240406193532409

目录

文章目录

    • 目录
    • 实验环境
    • 下载url
    • 安装相关包
    • 准备用户
    • 准备二进制程序
    • 准备环境变量
    • 准备配置文件
    • 生成数据库文件,并提取root密码
    • 准备服务脚本和启动
    • 修改口令
    • 测试登录
    • 安全初始化(可选)
    • shell一键安装
    • 关于我
    • 最后

实验环境

mysql-5.7.29
centos7.6 1810

软件位置:

链接:https://pan.baidu.com/s/1Q0y9RW4dFgEnmK5Vc3SKUg?pwd=q2sj
提取码:q2sj
2024.4.6-实战:通用二进制格式安装 MySQL(mysql-5.7.29)-2024.4.6(测试成功)

image-20240407064737911

下载url

https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz

image-20240406215438569

安装相关包

yum -y install libaio numactl-libs

准备用户

useradd -r -s /bin/false mysql

准备二进制程序

tar xf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz -C /usr/local
cd /usr/local/
ln -s mysql-5.7.29-linux-glibc2.12-x86_64/ mysql
chown -R root.root /usr/local/mysql/

准备环境变量

echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh

准备配置文件

cp /etc/my.cnf{,.bak}vim /etc/my.cnf
[mysqld]
datadir=/data/mysql
skip_name_resolve=1
socket=/data/mysql/mysql.sock        
log-error=/data/mysql/mysql.log
pid-file=/data/mysql/mysql.pid
[client]
socket=/data/mysql/mysql.sock

生成数据库文件,并提取root密码

mkdir -p /data/mysql
chown mysql:mysql /data/mysql
mysqld --initialize --user=mysql --datadir=/data/mysql ...省略...
2019-07-04T13:03:54.258140Z 1 [Note] A temporary password is generated for
root@localhost: LufavlMka6,!  #注意生成root的初始密码grep password /data/mysql/mysql.log
2019-12-26T13:31:30.458826Z 1 [Note] A temporary password is generated for
root@localhost: LufavlMka6,!awk '/temporary password/{print $NF}' /data/mysql/mysql.log
LufavlMka6,!

⚠️ 注意:

我这里实际测试时需要手动创建/data/mysql目录的,但老师当时测试时不需要直接创建的。

准备服务脚本和启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start

修改口令

mysqladmin -uroot -p'LufavlMka6,!'   password magedu

另外,自己这里测试时是需要到mysql里去修改密码的,使用mysqladmin是无法正常修改密码的;

自己这里测试时报错了:

[root@vm-template ~]#awk '/temporary password/{print $NF}' /data/mysql/mysql.log
?Ny,T;oKg5t>
[root@vm-template ~]#mysqladmin -uroot -p'?Ny,T;oKg5t>'   password magedu[root@vm-template ~]#mysqladmin -uroot -p'?Ny,T;oKg5t>'   password magedu
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin: connect to server at 'localhost' failed
error: 'Your password has expired. To log in you must change it using a client that supports expired passwords.'
[root@vm-template ~]#

📌 gpt

[root@vm-template ~]#mysqladmin -uroot -p'?Ny,T;oKg5t>'   password magedu
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin: connect to server at 'localhost' failed
error: 'Your password has expired. To log in you must change it using a client that supports expired passwords.'

当MySQL用户的密码过期时,您将无法用常规方法或常规客户端更改密码,因为它们可能不支持密码过期功能。在这种情况下,您需要使用支持密码过期的客户端来重置密码。对于MySQL,通常意味着您需要直接连接到MySQL服务器并通过命令行进行操作。

请按照以下步骤操作:

  1. 使用支持密码过期的MySQL客户端登录。打开终端,并尝试:

    mysql -uroot -p
    
  2. 系统会提示您输入密码,这时输入您的旧密码 ?Ny,T;oKg5t>

  3. 如果MySQL版本支持,登录后您可能会被提示修改密码。如果是,请按提示操作。

  4. 如果没有自动提示,或者提示不起作用,您可以在MySQL提示符下运行以下命令来设置新密码:

    SET PASSWORD = PASSWORD('您的新密码');
    

    或者,若MySQL版本为5.7.6或更新,应使用以下命令:

    ALTER USER 'root'@'localhost' IDENTIFIED BY '您的新密码';ALTER USER 'root'@'localhost' IDENTIFIED BY 'xyy520';
    

    请确保将 '您的新密码' 替换为您想要的新密码。

  5. 执行完上述命令后,退出MySQL:

    quit
    
  6. 现在您应该可以使用新密码通过mysqladmin或其他客户端工具连接到MySQL了。

如果您在这个过程中遇到任何问题,请再次检查您的MySQL服务器的版本和配置,因为不同版本可能需要略有不同的操作。

📌 再次测试(测试OK,符合预期)

[root@vm-template ~]#mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 5.7.29Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'xyy520';
Query OK, 0 rows affected (0.00 sec)mysql> \q
Bye
[root@vm-template ~]#mysql -uroot -pxyy520
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.7.29 MySQL Community Server (GPL)Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)mysql> \q
Bye
[root@vm-template ~]#

测试登录

[root@vm-template ~]#mysql -uroot -pxyy520
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.7.29 MySQL Community Server (GPL)Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)mysql> \q
Bye
[root@vm-template ~]#

安全初始化(可选)

#/usr/local/mysql/bin/mysql_secure_installationEnter current password for root (enter for none): #默认没密码,这里直接回车You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] #输入n(远程可以登录)#mysql.sock 使用unix socket登录(只能在本地登录,不能远程登录);
/var/lib/mysql/mysql.sock文件Change the root password? [Y/n] #输入y
New password: #输入密码:xyy520
Re-enter new password: Remove anonymous users? [Y/n] #输入yDisallow root login remotely? [Y/n] #输入y,禁用root远程登录Remove test database and access to it? [Y/n] #输入yReload privilege tables now? [Y/n] #输入y(是否加载权限)

shell一键安装

见如下位置:

次脚本测试成功,可一键部署的。

https://onedayxyy.cn/docs/mysql-install-bindary-shell-2

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

关于我

我的博客主旨:

  • 排版美观,语言精炼;
  • 文档即手册,步骤明细,拒绝埋坑,提供源码;
  • 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!

🍀 微信二维码

x2675263825 (舍得), qq:2675263825。

image-20230107215114763

🍀 微信公众号

《云原生架构师实战》

image-20230107215126971

🍀 个人博客站点

https://onedayxyy.cn/

🍀 语雀

https://www.yuque.com/xyy-onlyone

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

🍀 csdn

https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421

image-20230107215149885

🍀 知乎

https://www.zhihu.com/people/foryouone

image-20230107215203185

最后

好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!
https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421


http://www.ppmy.cn/news/1427685.html

相关文章

高频前端面试题汇总之Vue篇

1. Vue的基本原理 当一个Vue实例创建时,Vue会遍历data中的属性,用 Object.defineProperty(vue3.0使用proxy )将它们转为 getter/setter,并且在内部追踪相关依赖,在属性被访问和修改时通知变化。 每个组件实…

Linux 安装 Docker +Docker Compose + cucker/get_command_4_run_container

TIP:下面演示的 Linux 系统为 CentOS 7.9。 Docker 更新你的系统并安装必要的依赖项: sudo yum update -y sudo yum install -y yum-utils device-mapper-persistent-data lvm2添加 Docker 的官方仓库: sudo yum-config-manager --add-rep…

es安装中文分词器

下载地址,尽量选择和自己本地es差不多的版本 https://github.com/infinilabs/analysis-ik/releases 下载好,解压,把里面的文件放到es的plugins/ik目录下 把plugin-descriptor.properties文件里的es版本改成自己对应的 再启动es,能…

FlinkSQL State的生命周期

FlinkSQL未显示配置state生命周期 FlinkSQL默认没有配置state 的过期时间。也就是说默认情况是FlinkSQL从不清除状态。如果状态后端保存在rocksdb中,直到本地磁盘被打满,服务挂掉,报错如下: java.io.IOException: [bf3ba881614e…

【linux】centos7 开机 进单用户模式修改root密码

本站以分享各种运维经验和运维所需要的技能为主 《python零基础入门》:python零基础入门学习 《python运维脚本》: python运维脚本实践 《shell》:shell学习 《terraform》持续更新中:terraform_Aws学习零基础入门到最佳实战 《k8…

5G网络架构;6G网络架构

目录 5G和6G架构 6G网络架构 5G和6G架构 在设计和功能上有显著的区别,这主要体现在它们各自的核心特点、优势和应用场景上。 5G技术架构的核心特点包括高速率与低延迟、大容量与高密度以及网络切片。高速率与低延迟极大地提升了用户体验,支持更多实时应用和大规模数据传输…

[Kubernetes] etcd的集群基石作用

文章目录 1. 配置存储2. 数据一致性3. 服务发现与协调4. 集群状态中枢5. 集群稳定性 1. 配置存储 etcd作为一个高度可靠的分布式键值存储系统,存储了Kubernetes集群的完整配置和状态数据。集群的元数据,包括节点信息、命名空间、部署、副本集、服务、持…

物联网嵌入式ESP32开发实战,从基础到项目程序开发125例【doc.yotill.com】

一、ESP32基础入门例程开发 物联网嵌入式ESP32开发例程-ESP32实现ADC模拟量信号采集(ESP-IDF VSCode编程) 物联网嵌入式ESP32开发例程-ESP32实现RTC实时时钟(ESP-IDF VSCode编程) 物联网嵌入式ESP32开发例程-ESP32实现USB虚拟串口…