导读 MySQL是一种关系数据库管理系统(RDBMS),作为服务器运行,提供对多个数据库的多用户访问。 这是指导,如何在Fedora 28/27/26,CentOS 7.5 / 6.10和Red Hat(RHEL)7.5 / 6.10上安装或升级MySQL社区服务器最新版本8.0(8.0.12)/5.7(5.7.23)。 本指南当然也适用于Oracle Linux和Scientific Linux。

注意:如果要升级MySQL(从早期版本),请确保备份(转储和复制)数据库和配置。 记得运行mysql_upgrade。

安装 MySQL YUM 仓库源
## Fedora 28 ##
dnf install //dev.mysql.com/get/mysql80-community-release-fc28-1.noarch.rpm
## Fedora 27 ##
dnf install //dev.mysql.com/get/mysql80-community-release-fc27-1.noarch.rpm

## Fedora 26 ##
dnf install //dev.mysql.com/get/mysql80-community-release-fc26-1.noarch.rpm

CentOS 和 Red Hat (RHEL)
## CentOS 7 and Red Hat (RHEL) 7 ##
yum localinstall //dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

CentOS 6 and Red Hat (RHEL) 6 ##
yum localinstall //dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm
安装和更新

1.安装

Fedora 28/27/26
dnf install mysql-community-server
CentOS 7.5/6.10 and Red Hat (RHEL) 7.5/6.10
yum install mysql-community-server

2.安装 MySQL 5.7.23

Fedora 28/27/26

dnf --disablerepo=mysql80-community --enablerepo=mysql57-community install mysql-community-server

CentOS 7.5/6.10 and Red Hat (RHEL) 7.5/6.10

yum --disablerepo=mysql80-community --enablerepo=mysql57-community install mysql-community-server
3. 开启 MySQL server 并设置开机自启
Fedora 28/27/26  CentOS 7.5   Red Hat (RHEL) 7.5

systemctl start mysqld.service

use restart after update

systemctl enable mysqld.service

CentOS 6.10 and Red Hat (RHEL) 6.10

/etc/init.d/mysql start

use restart after update

OR ##

service mysql start   ## use restart after update

chkconfig --levels 235 mysqld on
4. 获取初始的随机密码
grep 'A temporary password is generated for root@localhost' /var/log/mysqld.log |tail -1

Example Output:

2018-11-20T21:11:44.229891Z 1 [Note] A temporary password is generated for root@localhost: -et)QoL4MLid

And root password is: -et)QoL4MLid

5.重置密码
alter user root@localhost identified by '自定义密码';
新密码必须大小学数字特殊符号全部具备。
6. 连接本地mysql服务器
mysql -u root -p OR ## mysql -h localhost -u root -p

本文原创地址://gulass.cn/fedora-mysql8.html作者:倪家兴,审核员:逄增宝

本文原创地址://gulass.cn/fedora-mysql8.html编辑:倪家兴,审核员:暂无