CentOS 8.x 安装 MySQL 8.x

官网找 MySQL 最新版本

https://dev.mysql.com/downloads/mysql/

 

目前最新版本是 8.0.28,执行 curl 下载最小化安装的 6 个 rpm 包

复制代码
复制代码
MYSQL_VERSION=8.0.28
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-community-common-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-community-client-plugins-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-community-libs-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-community-client-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-community-icu-data-files-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-community-server-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
复制代码
复制代码

 

依次安装 rpm 包,中间可能会报缺少 perl 及 net-tools,dnf 安装即可

复制代码
复制代码
rpm -ivh mysql-community-common-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
rpm -ivh mysql-community-client-plugins-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
rpm -ivh mysql-community-libs-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
rpm -ivh mysql-community-client-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
rpm -ivh mysql-community-icu-data-files-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
rpm -ivh mysql-community-server-${MYSQL_VERSION}-1.el8.$(uname -m).rpm
复制代码
复制代码

 

查看是否安装 mariadb,存在则删除,如:rpm -e --nodeps mariadb-libs

rpm -qa | grep mariadb

 

停止 mysqld 服务

systemctl stop mysqld

 

初始化数据库(时间有点长,耐心等待)

mysqld --initialize --console

 

目录授权

chown -R mysql:mysql /var/lib/mysql/

 

启动 mysqld 服务

systemctl start mysqld

 

查看临时密码

cat /var/log/mysqld.log

 

使用临时密码登录数据库

mysql -u root -p

 

修改 mysql 密码,并授权远程连接

alter USER 'root'@'localhost' IDENTIFIED BY '123456';
use mysql;
update user set host = "%" where user='root';
flush privileges;

 

关闭防火墙,使用 Navicat 测试数据库连接

systemctl stop firewalld
systemctl disable firewalld
posted @   吕金林  阅读(23)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
点击右上角即可分享
微信分享提示