在centos系统下,安装MYSQL

首先,我们的系统下是没有MYSQL的yum源的。

我们可以使用:ls /etc/yum.repos.d/ -l命令,查看当前系统中已经有的yum源。

1.那么我们如何添加MYSQL的yum源呢?

1.首先我们先到repo.mysql.com这个网址,下载对应的文件。

下载到Linux中是这样的文件

使用rpm -ivh mysql57-community-release-el7-9.noarch.rpm这条指令把我们刚刚的yum源添加到系统的yum源中。

上面的最后两行就有我们添加好的yum源了。

2.安装MYSQL的客户端和服务端

使用yum install -y mysql-community-server命令安装MYSQL服务

复制代码
安装遇到秘钥过期的问题:
Failing package is: mysql-community-client-5.7.39-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
解决⽅案:输入下面的命令
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

3.启动服务

因为安装的其实是两个程序,一个客户端,一个服务端。所以我们需要启动服务端

复制代码
[@VM-0-3-centos 9.9]$ systemctl start mysqld.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===

4.登录客户端

接下来我们需要使用我们的客户端来登录

由于刚开始登录需要密码,但是默认的密码我们不知道,我们可以在配置文件中添加skip-grant-tables选项,这样我们可以不用密码就登录,后续可以修改登录密码

复制代码
[root@bite-alicloud mysql]# vim /etc/my.cnf # 打开mysql配置⽂件
在[mysqld]最后⼀栏配置(不知道是什么,就放在配置⽂件最后) 加⼊: skip-grant-tables 选项,
并保存退出
[root@bite-alicloud mysql]# systemctl restart mysqld # 重启mysql服务
# 登陆成功
[root@bite-alicloud mysql]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.41 MySQL Community Server (GPL)
Copyright (c) 2000, 2023, 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.

修改完别忘记重启服务,让配置文件生效。

相关推荐
C_心欲无痕1 小时前
ts - tsconfig.json配置讲解
linux·前端·ubuntu·typescript·json
冰西瓜6002 小时前
国科大2025操作系统高级教程期末回忆版
linux
HIT_Weston2 小时前
93、【Ubuntu】【Hugo】搭建私人博客:面包屑(一)
linux·运维·ubuntu
cuijiecheng20183 小时前
Linux下Beyond Compare过期
linux·运维·服务器
HIT_Weston3 小时前
92、【Ubuntu】【Hugo】搭建私人博客:侧边导航栏(六)
linux·运维·ubuntu
CodeAllen嵌入式3 小时前
Windows 11 本地安装 WSL 支持 Ubuntu 24.04 完整指南
linux·运维·ubuntu
码农小韩5 小时前
基于Linux的C++学习——指针
linux·开发语言·c++·学习·算法
萧曵 丶5 小时前
MySQL 主键不推荐使用 UUID 的深层原因
数据库·mysql·索引
wdfk_prog5 小时前
[Linux]学习笔记系列 -- [fs]seq_file
linux·笔记·学习
Jay Chou why did5 小时前
wsl安装完无法进入wsl
linux