Linux中安装MySQL详细教程

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: Linux中安装MySQL详细教程

前言

现在红帽Linux上默认是没有yum源

yum软件仓库里面只有MariaDB的安装包所以我们需要自己先配置yum源


实验准备(以下操作在VMware中进行)

一台Linux主机 (我这里用的是RHEL7.4

已经联网

不要挂载yum镜像


1、配置yum源

下载yum源(我这里已经找好了)

wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm'

yum源下载链接:MySQL

安装yum源

rpm -Uvh mysql57-community-release-el7-11.noarch.rpm

查看有哪些版本的mysql

yum repolist all | grep mysql


2、安装

yum install -y mysql-community-server

3、启动mysql

注意启动的时候是mysqld而不是mysql

systemctl start mysqld

查看状态

systemctl status mysqld

4、登录数据库,修改数据库密码

找到密码: 红框的地方就是密码

[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
2020-12-18T15:15:55.572640Z 1 [Note] A temporary password is generated for root@localhost: 9sX3oDXGti)P
密码:9sX3oDXGti)P

5、登录MySQL

[root@localhost ~]# mysql -uroot -p'9sX3oDXGti)P'
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.32
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>    ---出现这个表示登录成功

查看数据库

mysql>show databases;     ---这里会报错,需要重新修改密码
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'XXGC.lab123';  
Query OK, 0 rows affected (0.01 sec)     ---表示修改成功

刷新

mysql> flush privileges;   
Query OK, 0 rows affected (0.00 sec)

退出

mysql> exit

6、使用新密码登录数据库

[root@localhost ~]# mysql -uroot -p'XXGC.lab123'
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.32 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>     ---登录成功

查看一下

mysql> show databses;  
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
mysql>

以上就是在RHEL7.4中配置MySQL的教程





相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1天前
|
关系型数据库 MySQL Linux
Linux下安装MySQL
Linux下安装MySQL
4 0
|
1天前
|
SQL 分布式计算 关系型数据库
Ubuntu上安装MySQL以及hive
Ubuntu上安装MySQL以及hive
9 1
|
1天前
|
SQL 关系型数据库 MySQL
Linux对MySQL语法校验
【5月更文挑战第4天】
|
2天前
|
关系型数据库 MySQL Linux
服务器Linux系统配置mysql数据库主从自动备份
这是一个基本的配置主从复制和设置自动备份的指南。具体的配置细节和命令可能因您的环境和需求而有所不同,因此建议在操作前详细阅读MySQL文档和相关资源,并谨慎操作以避免数据丢失或不一致。
11 3
|
3天前
|
关系型数据库 MySQL 数据库
mysqlTools 一分钟部署安装本mysql多个版本,解锁繁琐部署过程
mysqlTools 一分钟部署安装本mysql多个版本,解锁繁琐部署过程
63 2
|
4天前
|
关系型数据库 MySQL Linux
本地虚拟机centos7通过docker安装主从mysql5.7.21
本地虚拟机centos7通过docker安装主从mysql5.7.21
12 0
|
6天前
|
关系型数据库 MySQL 数据库
龙蜥操作系统上安装MySQL:步骤详解与常见问题解决
龙蜥操作系统上安装MySQL:步骤详解与常见问题解决
|
6天前
|
关系型数据库 MySQL Linux
在Centos7中:通过Docker安装MySQL5.7(保姆级)
在Centos7中:通过Docker安装MySQL5.7(保姆级)
|
6天前
|
编解码 安全 关系型数据库
祝福CSDN的小伙伴2024年快乐!Windows7安装MySQL
祝福CSDN的小伙伴2024年快乐!Windows7安装MySQL
|
6天前
|
SQL 关系型数据库 MySQL
MySQL最新版8.1.0安装配置教程
本文章,是对自己在安装最新版MySQL最新版8.1.0安装配置的一个详细过程吧,中间也有很多不清楚的地方,但是经过自己的多次对,工具环境以及软件环境的配置,现在对于这个的安装也算得心应手吧,不仅仅是一种总结,更是对自己经验的一种积累.