centos 7 安装mysql 8.0

centos 7 安装mysql 8.0

下载mysql包

解压安装包

powershell 复制代码
tar -xvf  mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar -C /目录

卸载系统以前安装的mysql

shell 复制代码
[root@localhost ~] rpm -qa | grep mariadb
 mariadb-libs-5.5.64-1.el7.x86_64
[root@localhost ~] rpm -e mariadb-libs-5.5.64-1.el7.x86_64 --nodeps
[root@localhost ~] rpm -qa | grep mariadb
[root@localhost ~] reboot

安装mysql

shell 复制代码
rpm -ivh mysql-community-client-plugins-8.0.27-1.el7.x86_64.rp
rpm -ivh mysql-community-common-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.27-1.el7.x86_64.rpm
rpm -ivh  mysql-community-server-8.0.27-1.el7.x86_64.rpm

如果有如下错误

shell 复制代码
[root@liunx1 mysql]# rpm -ivh  mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm 
警告:mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm: 头V3 DSA/SHA256 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
	软件包 mysql-community-client-plugins-8.0.27-1.el7.x86_64 已经安装
[root@liunx1 mysql]# rpm -ivh mysql-community-common-8.0.27-1.el7.x86_64.rpm 
警告:mysql-community-common-8.0.27-1.el7.x86_64.rpm: 头V3 DSA/SHA256 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
	软件包 mysql-community-common-8.0.28-1.el8.x86_64 (比 mysql-community-common-8.0.27-1.el7.x86_64 还要新) 已经安装

则执行如下进行卸载

shell 复制代码
 rpm -e mysql-community-common-8.0.28-1.el8.x86_64  --nodeps

如果安装出现

shell 复制代码
[root@localhost opt]# rpm -ivh /opt/server/mysql-community-common-8.0.19-		1.el7.x86_64.rpm
警告:/opt/server/mysql-community-common-8.0.19-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
1:mysql-community-common-8.0.19-1.e################################# [100%]

则依次执行如下命令

shell 复制代码
yum search perl
yum search libaio 
yum search net-tools
yum -y install perl.x86_64
yum install -y libaio.x86_64
yum -y install net-tools.x86_64

在安装mysql-community-server-8.0.27-1.el7.x86_64.rpm

shell 复制代码
rpm -ivh mysql-community-server-8.0.27-1.el7.x86_64.rpm

启动并检查mysql服务

shell 复制代码
#启动mysql
systemctl start mysqld

#查看服务状态
systemctl status mysqld
[root@liunx1 mysql]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2024-03-09 10:25:37 CST; 2min 14s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 1946 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 2024 (mysqld)
   Status: "Server is operational"
    Tasks: 37
   Memory: 477.6M
   CGroup: /system.slice/mysqld.service
           └─2024 /usr/sbin/mysqld

登录mysql服务

shell 复制代码
[root@localhost opt]# mysql -u root -p
Enter password: 
【注意】初始密码在 /var/log/mysqld.log中可以查看到

修改root用户密码

注意: 第一次登录必须要修改初始密码之后才能对数据库进行操作

shell 复制代码
# 修改用户密码
 ALTER USER 'root'@'localhost' IDENTIFIED BY 'Alvin.123456';

临时修改用户密码策略并添加用户

  • 密码策略
    validate_password.policy 值可以使用数值 0、1、2 或相应的符号值 来指定,。下表描述了为每个策略执行的测试:
Policy Tests Performed
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file
shell 复制代码
#查看密码验证策略
show variables like 'validate_password.%';
#修改密码策略
set global validate_password.policy=0;
set global validate_password.length=6;
# 创建root@%用户
create user 'root'@'%' identified by '123456';
#修改密码验证方式,让低版本的navicat通过验证
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
# 授权用户最高权限
grant all privileges ON *.* TO 'root'@'%' with grant option;
# 修改root@localhost用户密码为123456
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
#刷新权限
flush privileges;
相关推荐
qq_297574674 小时前
Linux 服务器 Java 开发环境搭建保姆级教程
java·linux·服务器
70asunflower4 小时前
Emulation,Simulation,Virtualization,Imitation 的区别?
linux·docker
神梦流5 小时前
GE 引擎的内存优化终局:静态生命周期分析指导下的内存分配与复用策略
linux·运维·服务器
凡人叶枫5 小时前
C++中输入、输出和文件操作详解(Linux实战版)| 从基础到项目落地,避坑指南
linux·服务器·c语言·开发语言·c++
wdfk_prog5 小时前
[Linux]学习笔记系列 -- [drivers][input]serio
linux·笔记·学习
xuhe26 小时前
[全流程详细教程]Docker部署ClawBot, 使用GLM4.7, 接入TG Bot实现私人助理. 解决Docker Openclaw Permission Denied问题
linux·docker·ai·github·tldr
洛豳枭薰6 小时前
Innodb一次更新动作
mysql
Lsir10110_6 小时前
【Linux】进程信号(下半)
linux·运维·服务器
酉鬼女又兒6 小时前
零基础入门Linux指南:每天一个Linux命令_pwd
linux·运维·服务器
云飞云共享云桌面6 小时前
高性能图形工作站的资源如何共享给10个SolidWorks研发设计用
linux·运维·服务器·前端·网络·数据库·人工智能