文档课题:rhel 7.3安装mysql 5.7.21
安装包:mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
1、上传安装包
[root@leo-mysql5721 ~]# mkdir -p /u01/setup/db
sftp> lcd F:\installmedium\mysql\MySQL-5.7.21
sftp> cd /u01/setup/db
sftp> put mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar/
2、开始安装
2.1、解压安装包
[root@leo-mysql5721 db]# tar -xvf mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
mysql-community-embedded-devel-5.7.21-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.21-1.el7.x86_64.rpm
mysql-community-common-5.7.21-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.21-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.21-1.el7.x86_64.rpm
mysql-community-client-5.7.21-1.el7.x86_64.rpm
mysql-community-server-5.7.21-1.el7.x86_64.rpm
mysql-community-embedded-5.7.21-1.el7.x86_64.rpm
mysql-community-test-5.7.21-1.el7.x86_64.rpm
mysql-community-devel-5.7.21-1.el7.x86_64.rpm
mysql-community-libs-5.7.21-1.el7.x86_64.rpm
说明:解压出来的rpm包,只需要以下4个.
mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.21-1.el7.x86_64.rpm
mysql-community-client-5.7.21-1.el7.x86_64.rpm
mysql-community-common-5.7.21-1.el7.x86_64.rpm
2.2、卸载mariadb
[root@leo-mysql5721 db]# rpm -qa | grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@leo-mysql5721 db]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
说明:rhel 7.3默认安装了mariadb-lib库,而mysql-5.7不兼容该库,所以需要卸载.
2.3、安装mysql
--先安装mysql-common
[root@leo-mysql5721 db]# rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-common-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################################# [100%]
--在安装mysql-libs
[root@leo-mysql5721 db]# rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.21-1.el7################################# [100%]
--然后安装mysql-client
[root@leo-mysql5721 db]# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm
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-client-5.7.21-1.e################################# [100%]
--最后安装mysql-server
[root@leo-mysql5721 db]# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.21-1.e################################# [100%]
3、相关设置
3.1、启动mysql
[root@leo-mysql5721 log]# systemctl start mysqld
或者
[root@leo-mysql5721 log]# service mysqld start
说明:若mysql服务无法启动,查看mysqld.log日志文件.
3.2、密码确认
启动服务后,mysql会生成一个默认的初始密码.
[root@leo-mysql5721 log]# cat mysqld.log | grep password
2023-05-21T15:25:20.240359Z 1 [Note] A temporary password is generated for root@localhost: ,CVBrhGbn3Nl
2023-05-21T15:27:14.670105Z 2 [Note] Access denied for user 'root'@'localhost' (using password: YES)
说明:root@localhost:后的内容为登录mysql密码.
3.4、修改密码
[root@leo-mysql5721 log]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.21
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> select version();
+-----------+
| version() |
+-----------+
| 5.7.21 |
+-----------+
1 row in set (0.00 sec)
--mysql5.7密码策略默认设置得比较高,既要求密码中有大小写字母,要有数字,还要有特殊字符,所以将策略调低.
mysql> set global validate_password_policy=low;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user root@localhost identified by 'mysql_4U';
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.00 sec)
到此,mysql-5.7.21在rhel 7.3安装完毕.
参考网址:https://blog.csdn.net/Michael__One/article/details/103795276
标签:21,5.7,7.3,64,mysql,rpm,el7
From: https://blog.51cto.com/u_12991611/6323338