概述

由于环境需要需安装部署MySQL服务。

安装

下载MySQLRPM包并解压
如较慢可使用:https://file.lolicp.com/Package/MySql/8.0/mysql-8.0.25-1.el7.x86_64.rpm-bundle.tar
[root@master-all ~]# Mysql_Version=8.0.25
[root@master-all ~]# wget https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-${Mysql_Version}-1.el7.x86_64.rpm-bundle.tar
[root@master-all ~]# tar xf mysql-${Mysql_Version}-1.el7.x86_64.rpm-bundle.tar
卸载原有的mysql及mysql-libs
[root@master-all ~]# rpm -e mysql mysql-libs --nodeps
RPM安装MySQL并启动
[root@master-all ~]# rpm -e mariadb-libs --nodeps
[root@master-all ~]# rpm -ivh mysql-community-common-${Mysql_Version}-1.el7.x86_64.rpm
[root@master-all ~]# rpm -ivh mysql-community-client-plugins-${Mysql_Version}-1.el7.x86_64.rpm
[root@master-all ~]# rpm -ivh mysql-community-libs-${Mysql_Version}-1.el7.x86_64.rpm
[root@master-all ~]# rpm -ivh mysql-community-client-${Mysql_Version}-1.el7.x86_64.rpm
[root@master-all ~]# rpm -ivh mysql-community-server-${Mysql_Version}-1.el7.x86_64.rpm
[root@master-all ~]# rpm -ivh mysql-community-devel-${Mysql_Version}-1.el7.x86_64.rpm
[root@master-all ~]# rpm -ivh mysql-community-libs-compat-${Mysql_Version}-1.el7.x86_64.rpm
[root@master-all ~]# systemctl start mysqld
[root@master-all ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
获取MySQL默认root密码并更改

密码格式必须8位数大写字母+数字+特殊符号

[root@master ~]# awk '/temporary password/ {print $13}' /var/log/mysqld.log
DK#Q:60mw-i;
[root@master-all ~]# mysql -uroot -p'DK#Q:60mw-i;'
# 变更root默认密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Ymcc231@!';
# 创建用户密码强度同上,授权用户tests于本地登陆密码为
mysql> create user'tests'@'localhost' identified by 'Ymcc898@!';
[root@master-all ~]# mysql --version
mysql  Ver 8.0.25 for Linux on x86_64 (MySQL Community Server - GPL)
遇到的问题

报错:

[root@master ~]# rpm -ivh mysql-community-libs-${Mysql_Version}-1.el7.x86_64.rpm 
error: Failed dependencies:
    mariadb-libs is obsoleted by mysql-community-libs-8.0.25-1.el7.x86_64

解决方法:

[root@master ~]# rpm -e mariadb-libs --nodeps
END

本文标题:Mysql 8.0 RPM安装教程

本文作者:宇宙最帅的男人

本文链接:https://lolicp.com/mysql/20211517.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归 (lolicp.com) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2024 年 10 月 06 日
如果觉得我的文章对你有用,请随意赞赏