CentOS 7 如何使用rpm安装单节点的MySQL

使用rpm安装MySQL的方法:首先下载rpm包,当然小编为大家准备好了rpm包,大家可以直接去下载,也可以自行去寻找合适的rpm包进行安装。

①rpm包下载

MySQL5.7.21 rpm包下载路径
无论是哪种方式下载的rpm包,接下来都需要上传到需要安装MySQL的服务器上,小编使用的是FileZilla工具进行上传文件到服务器。
CentOS 7 如何使用rpm安装单节点的MySQL
等待文件上传完成之后,我们就需要进入到对应的上传目录下,进行安装。小编使用的是最粗暴的安装方式进行安装:

② rpm包安装
[root@admin01 2]# rpm -ivh *.rpm --nodeps --force
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.21-1.e################################# [  8%]
   2:mysql-community-libs-5.7.21-1.el7################################# [ 17%]
   3:mysql-community-client-5.7.21-1.e################################# [ 25%]
   4:mysql-community-server-5.7.21-1.e################################# [ 33%]
   5:mysql-community-devel-5.7.21-1.el################################# [ 42%]
   6:mysql-community-embedded-5.7.21-1################################# [ 50%]
   7:mysql-community-embedded-devel-5.################################# [ 58%]
   8:mysql-community-test-5.7.21-1.el7################################# [ 67%]
   9:mysql-community-libs-compat-5.7.2################################# [ 75%]
  10:mysql-community-embedded-compat-5################################# [ 83%]
  11:mysql-community-server-minimal-5.################################# [ 92%]
  12:mysql-community-minimal-debuginfo################################# [100%]

可以看见上面的MySQL已经成功安装,MySQL的安装并不需要这么多的rpm包,大家也可以根据自已的需要选择需要的rpm包进行安装。

③ 启动MySQL
[root@admin01 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-11-22 08:36:35 EST; 19s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 2006 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 1933 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 2009 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─2009 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Nov 22 08:36:21 admin01 systemd[1]: Starting MySQL Server...
Nov 22 08:36:35 admin01 systemd[1]: Started MySQL Server.
④修改my.cnf

默认MySQL的配置文件在/etc/my.cnf,找到该文件根据项目需要进行配置。修改完成后记得重启MySQL。

⑤获取MySQL的初始密码
[root@admin01 ~]# grep 'A temporary password' /data/mysql/mysqld.log | awk -F"root@localhost: " '{ print $2}' 
xdFqs#DE;3gx
⑥修改MySQL的密码
[root@admin01 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.21-log

Copyright (c) 2000, 2018, 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> set global validate_password_policy = 0;
Query OK, 0 rows affected (0.00 sec)
#修改MySQL的密码
mysql> SET PASSWORD = PASSWORD('icloud20210415081632');
Query OK, 0 rows affected, 1 warning (0.00 sec)
#重新加载
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
上一篇:nacos进阶二--使用源码启动项目


下一篇:P3389 【模板】高斯消元法 题解