海滨擎蟹

常用的 yum 指令

安装(比如:mysql):

# -y 表示:针对安装过程中的提问,默认 yes
# mysql 表示:要安装的库名,也有可能其他形式的名称:mysql-community-server
yum [-y] install mysql

搜索当前库(比如:mysql):

yum search mysql

搜索潜在的库(比如:mysql):

yum repolist all | grep mysql

结果:

mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community   disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community   disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
mysql-connectors-community/x86_64  MySQL Connectors Community    enabled:     95
mysql-connectors-community-source  MySQL Connectors Community -  disabled
mysql-tools-community/x86_64       MySQL Tools Community         enabled:     84
mysql-tools-community-source       MySQL Tools Community - Sourc disabled
mysql-tools-preview/x86_64         MySQL Tools Preview           disabled
mysql-tools-preview-source         MySQL Tools Preview - Source  disabled
mysql55-community/x86_64           MySQL 5.5 Community Server    disabled
mysql55-community-source           MySQL 5.5 Community Server -  disabled
mysql56-community/x86_64           MySQL 5.6 Community Server    disabled
mysql56-community-source           MySQL 5.6 Community Server -  disabled
mysql57-community/x86_64           MySQL 5.7 Community Server    enabled:    327
mysql57-community-source           MySQL 5.7 Community Server -  disabled
mysql80-community/x86_64           MySQL 8.0 Community Server    disabled
mysql80-community-source           MySQL 8.0 Community Server -  disabled

切换默认安装的库(比如:mysql):

当前默认安装的是 8.0 版本,切换到 5.7 版本。

yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community

yum-config-manager包含在 yum 扩展包内,默认情况下,是未安装的。

执行以下指令安装:

yum -y install yum-utils

附:mysql 5.7 安装后的默认操作

启动、关闭、查看状态:
service mysqld start\stop\status
基于EL7的平台,操作指令由 service 改成了 systemctl,如下:
systemctl start\stop\status mysqld.service

初次启动 mysql 5.7 回执行以下操作:

获取密码:

grep 'temporary password' /var/log/mysqld.log

尽快用生成的临时密码登录,并设置一个新的密码,以完成密码修改。

mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

默认安装的 validate_password 插件会要求密码至少包含一个大写字母,一个小写字母,一个数字和一个特殊字符,并且完整的密码至少 8 位。

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »