当前位置: 首页 > news >正文

Linux(CentOS 7) yum一键安装mysql8

1、通过yum安装

(1)下载mysql 

 在Linux找个地方输入以下命令

wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

(2)安装mysql yum 仓库配置文件

[root@VM-8-15-centos ~]# sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm

(3)先清理缓存(可能以前被操作过)

[root@VM-8-15-centos ~]#  sudo yum clean all

(4)生成缓存

[root@VM-8-15-centos ~]# sudo yum makecache

(5)安装Mysql

[root@VM-8-15-centos ~]# sudo yum install mysql-community-server 

如果报异常:

The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
 Failing package is: mysql-community-client-plugins-8.0.40-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

那么就重新来过一次,添加 --nogpgcheck

[root@VM-8-15-centos ~]#sudo yum install mysql-community-server --nogpgcheck

(6)启动Mysql服务

[root@VM-8-15-centos ~]# sudo systemctl start mysqld

(7)设置开机启动

[root@VM-8-15-centos ~]# sudo systemctl enable mysqld

(8)查看Mysql 服务状态

[root@VM-8-15-centos ~]# sudo systemctl status mysqld
● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: active (running) since Tue 2024-11-12 17:49:35 CST; 1min 13s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlMain PID: 29395 (mysqld)Status: "Server is operational"CGroup: /system.slice/mysqld.service└─29395 /usr/sbin/mysqldNov 12 17:49:27 VM-8-15-centos systemd[1]: Starting MySQL Server...
Nov 12 17:49:35 VM-8-15-centos systemd[1]: Started MySQL Server.

2、登录Mysql

(1)查找临时登录密码

[root@VM-8-15-centos log]# sudo grep 'temporary password' /var/log/mysqld.log
2024-11-12T09:49:30.521947Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: g.<we6/h<W7f

(2)输入密码并且修改密码(密码规则是4种类型字符)

登录命令:  mysql -u root -p

修改密码:set password for root@localhost='Admin123!';

[root@VM-8-15-centos log]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.40Copyright (c) 2000, 2024, 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.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> set password for root@localhost='Admin123!';
Query OK, 0 rows affected (0.01 sec)

3、修改远程链接并且生效

 (1)选中mysql数据库

mysql> use mysql;

(2)设置允许远程连接并生效

mysql> update user set host='%' where user='root'; 
mysql> flush privileges;

        root表示想要被连接的数据库的用户名
        其中“%”表示允许所有机器能访问root用户

(3)开放防火墙3306端口

mysql已经可以本地连接上了,但要用图形化界面远程连接,需开放防火墙的3306端口才行

--permanent代表永久生效,否则重启linux后则需要再次开启

 [root@localhost mysql-8.0]# firewall-cmd --add-port=3306/tcp --permanent[root@localhost mysql-8.0]# firewall-cmd --reload

  查看防火墙端口开放状态

[root@localhost mysql-8.0]# firewall-cmd --list-all

        自此在linux系统上安装mysql8已经完成,并且可以使用图形化界面远程连接

18. 可视化界面链接mysql

     我这里是使用Navicat for MySQL 

     获取数据库IP:

[root@localhost mysql-8.0]# ifconfig

 inet  192.200.xx.xx 就是你服务器的地址

 输入链接IP、账号root、密码123456,端口号 3306,显示“连接成功”代表流程通了 

http://www.lryc.cn/news/482512.html

相关文章:

  • Kafka 快速入门(一)
  • 丹摩征文活动 | SD3+ComfyUI的图像部署实践
  • H.265流媒体播放器EasyPlayer.js网页web无插件播放器:如何优化加载速度
  • 【Linux】进程状态的优先级
  • react中的组件传参
  • HTML5:网页开发的新纪元
  • CKA认证 | Day2 K8s内部监控与日志
  • 电信网关配置管理系统 upload_channels.php 文件上传致RCE漏洞复现
  • ubuntu更改max_map_count
  • 《NPU、CPU、GPU 算力定义和计算方式》
  • 初级数据结构——顺序表
  • 游戏引擎学习第五天
  • 智能社区服务小程序+ssm
  • glide性能优化实战
  • Python 环境搭建和安装(保姆级教程)
  • Java并发编程(二):同步机制与多线程是否矛盾
  • golang分布式缓存项目 Day2 单机并发缓存
  • 一个百度、必应搜索引擎图片获取下载的工具包
  • 安全见闻(网络安全篇)
  • 手写一些方法
  • 仅需三步!用AI工具免费打造10w+抖音爆款烟火秀视频教程
  • 基于redis实现API接口访问次数限制
  • [ Linux 命令基础 3 ] Linux 命令详解-文件和目录管理命令
  • npm i 的时候报错: npm ERR! Error: EPERM: operation not permitted, rename
  • 如何迁移剪映源文件
  • Go语言中的`io.Copy`函数:高效的数据复制解决方案
  • datastage在升级版本到11.7之后,部分在11.3上正常执行的SP报错SQLSTATE = 22007: 本机错误代码 = -180
  • docker——项目部署
  • 设计模式(Unity)——更新中
  • 小程序中引入下载到本地的iconfont字体图标加载不出来问题解决