51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Mysql 8.0 RPM安装教程

概述

由于环境需要需安装部署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
赞(1)
未经允许不得转载:工具盒子 » Mysql 8.0 RPM安装教程