自己怎么做免费网站空间/市场营销活动策划方案
数据库系统原理与应用教程(005)—— yum 离线安装 MySQL5.7(Linux 环境)
目录
一、卸载 MariaDB
[root@localhost Packages]# rpm -ivh lrzsz-0.12.20-36.el7.x86_64.rpm
警告:lrzsz-0.12.20-36.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...1:lrzsz-0.12.20-36.el7 ################################# [100%]
[root@localhost Packages]# yum remove -y mariadb-libs
已加载插件:fastestmirror
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb-libs.x86_64.1.5.5.52-1.el7 将被 删除
--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 2:postfix-2.10.1-6.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 2:postfix-2.10.1-6.el7.x86_64 需要
--> 正在检查事务
---> 软件包 postfix.x86_64.2.2.10.1-6.el7 将被 删除
--> 解决依赖关系完成依赖关系解决===================================================================================================Package 架构 版本 源 大小
===================================================================================================
正在删除:mariadb-libs x86_64 1:5.5.52-1.el7 @anaconda 4.4 M
为依赖而移除:postfix x86_64 2:2.10.1-6.el7 @anaconda 12 M事务概要
====================================================================================================
移除 1 软件包 (+1 依赖软件包)安装大小:17 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。正在删除 : 2:postfix-2.10.1-6.el7.x86_64 1/2 正在删除 : 1:mariadb-libs-5.5.52-1.el7.x86_64 2/2 验证中 : 2:postfix-2.10.1-6.el7.x86_64 1/2 验证中 : 1:mariadb-libs-5.5.52-1.el7.x86_64 2/2 删除:mariadb-libs.x86_64 1:5.5.52-1.el7 作为依赖被删除:postfix.x86_64 2:2.10.1-6.el7 完毕!
二、把所需的 rpm 包上传到服务器
[root@localhost mysql-soft]# pwd
/soft/mysql-soft
[root@localhost mysql-soft]# rz[root@localhost mysql-soft]# ll
总用量 196704
-rw-r--r--. 1 root root 25365436 6月 12 2019 mysql-community-client-5.7.27-1.el7.x86_64.rpm
-rw-r--r--. 1 root root 281248 6月 12 2019 mysql-community-common-5.7.27-1.el7.x86_64.rpm
-rw-r--r--. 1 root root 2272032 6月 12 2019 mysql-community-libs-5.7.27-1.el7.x86_64.rpm
-rw-r--r--. 1 root root 173500088 6月 12 2019 mysql-community-server-5.7.27-1.el7.x86_64.rpm
三、安装 rpm 包
[root@localhost mysql-soft]# rpm -ivh --nodeps --force *.rpm
警告:mysql-community-client-5.7.27-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...1:mysql-community-common-5.7.27-1.e################################# [ 25%]2:mysql-community-libs-5.7.27-1.el7################################# [ 50%]3:mysql-community-client-5.7.27-1.e################################# [ 75%]4:mysql-community-server-5.7.27-1.e################################# [100%]
四、配置 MySQL 操作环境
1、启动 MySQL 服务
[root@localhost mysql-soft]# systemctl restart mysqld
2、查看 MySQL 相关的文件与目录
[root@localhost mysql-soft]# find / -name mysql*
/etc/selinux/targeted/active/modules/100/mysql
/etc/logrotate.d/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/bin/mysql
/usr/lib64/mysql
/usr/share/mysql# MySQL 的配置文件
[root@localhost mysql-soft]# ll /etc/my.cnf
-rw-r--r--. 1 root root 960 6月 10 2019 /etc/my.cnf# MySQL 的日志文件
[root@localhost mysql-soft]# ll /var/log/mysqld.log
-rw-r-----. 1 mysql mysql 3795 6月 26 19:14 /var/log/mysqld.log# MySQL 的启动脚本
[root@localhost mysql-soft]# ll /usr/lib/systemd/system/mysqld.service
-rw-r--r--. 1 root root 1614 6月 10 2019 /usr/lib/systemd/system/mysqld.service# MySQL 的进程文件
[root@localhost mysql-soft]# ll /var/run/mysqld/mysqld.pid
-rw-r-----. 1 mysql mysql 5 6月 26 19:14 /var/run/mysqld/mysqld.pid# socket 文件
[root@localhost mysql-soft]# ll /var/lib/mysql/mysql.sock
srwxrwxrwx. 1 mysql mysql 0 6月 26 19:14 /var/lib/mysql/mysql.sock
3、查看 MySQL 默认的 root 账户密码
MySQL 安装完成之后,会为 root 账户 生成一个默认密码。通过下面的方式可以查看默认密码。
[root@localhost mysql-soft]# grep 'temporary password' /var/log/mysqld.log
2022-06-26T11:14:04.385266Z 1 [Note] A temporary password is generated for root@localhost: QFh7LiP8-r#c
4、使用默认密码登录 MySQL
[root@localhost mysql-soft]# mysql -uroot -pQFh7LiP8-r#c
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 2
Server version: 5.7.27Copyright (c) 2000, 2019, 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>
5、修改 root 账号的密码
mysql> alter user 'root'@'localhost' identified by 'Wgx123456.';
Query OK, 0 rows affected (0.00 sec)
6、使用新密码登录 MySQL
[root@localhost mysql-soft]# mysql -uroot -pWgx123456.
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 3
Server version: 5.7.27 MySQL Community Server (GPL)Copyright (c) 2000, 2019, 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>