你的浏览器不支持canvas

做你害怕做的事情,然后你会发现,不过如此。

linux离线安装MySql5.7

时间: 作者: 黄运鑫

本文章属原创文章,未经作者许可,禁止转载,复制,下载,以及用作商业用途。原作者保留所有解释权。


下载MySql5.7

安装

  • 将安装包mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar上传到服务器任意目录下
  • 执行tar -xvf mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar解压安装包
  • 执行rpm -ivh *.rpm --force --nodeps安装刚才解压后的文件,结果如下:
[root@ngd-app1 mysql]# rpm -ivh *.rpm --force --nodeps
warning: mysql-community-client-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.37-1.e################################# [ 10%]
   2:mysql-community-libs-5.7.37-1.el7################################# [ 20%]
   3:mysql-community-client-5.7.37-1.e################################# [ 30%]
   4:mysql-community-server-5.7.37-1.e################################# [ 40%]
   5:mysql-community-devel-5.7.37-1.el################################# [ 50%]
   6:mysql-community-embedded-5.7.37-1################################# [ 60%]
   7:mysql-community-embedded-devel-5.################################# [ 70%]
   8:mysql-community-test-5.7.37-1.el7################################# [ 80%]
   9:mysql-community-libs-compat-5.7.3################################# [ 90%]
  10:mysql-community-embedded-compat-5################################# [100%]
  • 执行rpm -qa | grep mysql验证是否安装,结果如下:
[root@ngd-app1 mysql]# rpm -qa | grep mysql
mysql-community-libs-5.7.37-1.el7.x86_64
mysql-community-embedded-5.7.37-1.el7.x86_64
mysql-community-embedded-compat-5.7.37-1.el7.x86_64
mysql-community-common-5.7.37-1.el7.x86_64
mysql-community-client-5.7.37-1.el7.x86_64
mysql-community-devel-5.7.37-1.el7.x86_64
mysql-community-embedded-devel-5.7.37-1.el7.x86_64
mysql-community-libs-compat-5.7.37-1.el7.x86_64
mysql-community-server-5.7.37-1.el7.x86_64
mysql-community-test-5.7.37-1.el7.x86_64

启动

  • 执行systemctl start mysqld启动mysql
  • 执行systemctl enable mysqld添加到开机启动
  • 执行systemctl status mysqld查看启动状态,结果如下:
root@ngd-app1 mysql]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2022-04-23 18:02:16 CST; 24s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 22389 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 22166 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 22392 (mysqld)
    Tasks: 27
   Memory: 324.7M
   CGroup: /system.slice/mysqld.service
           └─22392 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysql...

Apr 23 18:01:58 ngd-app1 systemd[1]: Starting MySQL Server...
Apr 23 18:02:16 ngd-app1 systemd[1]: Started MySQL Server.

登录

  • 执行cat /var/log/mysqld.log | grep password查看默认密码,结果如下:
[root@ngd-app1 mysql]# cat /var/log/mysqld.log | grep password
2022-04-23T10:02:10.017211Z 1 [Note] A temporary password is generated for root@localhost: bh5l+uAg.c6q
  • 执行mysql -uroot -p,输入刚才的默认密码登录mysql,结果如下:
[root@ngd-app1 mysql]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37

Copyright (c) 2000, 2022, 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> 
  • 执行ALTER USER USER() IDENTIFIED BY '新密码';重置默认密码,安装完成

对于本文内容有问题或建议的小伙伴,欢迎在文章底部留言交流讨论。