赞
踩
1、转到MySQL yum repository的下载页面https://dev.mysql.com/downloads/repo/yum/
下载你需要的文件
示例:
shell> sudo rpm -Uvh platform-and-version-specific-package-name.rpm
因为我下载的是mysql80-community-release-el8-1.noarch.rpm,所以命令为:
shell> sudo rpm -Uvh mysql80-community-release-el8-1.noarch.rpm
如图,你不想安装mysql80-community,而是想选择mysql57-community。可以选择以下三种中任意一种方式进行操作:
注: 在任何时候应该只有一个发行版系列被启用。当为多个版本系列时,yum将使用最新的系列。
方式一、使用yum config manager来修改
命令如下:
shell> sudo yum-config-manager --disable mysql80-community
shell> sudo yum-config-manager --enable mysql57-community
方式二、通过dnf config manager命令来修改
命令如下:
shell> sudo dnf config-manager --disable mysql80-community
shell> sudo dnf config-manager --enable mysql57-community
方式三、修改配置文件 /etc/yum.repos.d/mysql-community.repo
经典条目为:
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
现在需要做的是将mysql80-community中enabled=1设置为0,将mysql57-community中enabled=0变更为1
# Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
shell> yum repolist enabled | grep mysql
对于centos8、RHEL8 和 Oracle Linux 8还需要进行其他操作:
官方解释如下:(EL8 systems only) EL8-based systems such as RHEL8 and Oracle Linux 8 include a MySQL module that is enabled by default. Unless this module is disabled, it masks packages provided by MySQL repositories. To disable the included module and make the MySQL repository packages visible, use the following command (for dnf-enabled systems, replace yum in the command with dnf)
意思是:(仅限EL8系统)基于EL8的系统(如RHEL8和oracle linux8)包含默认启用的MySQL模块。除非禁用此模块,否则它将屏蔽MySQL存储库提供的包。要禁用包含的模块并使MySQL存储库包可见,请使用以下命令(对于启用dnf的系统,请将命令中的yum替换为dnf)
需要执行命令:
shell> sudo yum module disable mysql
执行
shell> sudo yum install mysql-community-server
正常安装
6.1、启动,查看状态
shell> systemctl start mysqld #启动数据库
shell> systemctl status mysqld #查看数据库状态
6.2、修改密码
注: 默认情况下安装MySQL的validate_password 密码插件。这将要求密码至少包含一个大写字母、一个小写字母、一个数字和一个特殊字符,并且密码总长度至少为8个字符。
[root@node-1 opt]# sudo grep 'temporary password' /var/log/mysqld.log
2021-01-09T10:48:13.359235Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rDEi!W,>V5rS
[root@node-1 opt]#
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
示例:
[root@node-1 opt]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.22 Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码'; Query OK, 0 rows affected (0.05 sec) mysql> exit Bye [root@node-1 opt]# [root@node-1 opt]# [root@node-1 opt]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 8.0.22 MySQL Community Server - GPL Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> exit Bye [root@node-1 opt]#
参考文档:https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。