CentOS 8 yum 安装Redis ,安装Golang,RPM安装MySQL

2021-11-11 14:06:17

国内的话建议修改yum源为阿里云,修改方法参考: CentOS 8修改yum源为国内源

1.添加EPEL仓库

在CentOS或Red Hat系统中,需要先添加EPEL仓库

  1.  #添加EPEL仓库

  2.  sudo yum install epel-release

  3.  #更新yum源

  4. sudo yum update

2.安装

yum install redis

3.启动

systemctl start redis

4.设置开机自启

systemctl enable redis

5.修改配置

打开/etc/redis.conf文件。

1)允许远程连接

找到下面这一行,注释掉:

bind 127.0.0.1

改为:

#bind 127.0.0.1

2)启用密码

找到# requirepass foobared一行,删除前面的#注释,然后将foobared改为你自己的密码。

requirepass your_password

6.开放端口

如果启用了防火墙,redis默认端口6379需要进行开放,开放端口参考: CentOS开放端口的方法 。

  1.  sudo firewall-cmd --add-port=6379/tcp --permanent 

  2.  sudo firewall-cmd --reload 

  3. systemctl restart redis

7.测试远程连接

telnet id 6379

命令行安装

yum install golang

默认安装目录/usr/lib/golang/  (不同系统不一样,可通过搜索golang关键字查找: find / -name golang)

卸载

yum remove golang

配置环境变量

# 打开
vim /etc/profile
# 添加
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
# 编译
source /etc/profile


是否需要配置GOPATH

Go的1.11版本之后,已不再推荐使用GOPATH来构建应用了,使用Module方式构建


MySQL8.0 Bundle RPM安装过程

清理旧的mysql环境

1、查看当前安装的相关包


rpm -qa|grep -i mysql

也可能是

rpm -qa|grep -i mariadb

a、卸载相关包,如


rpm -e --nodeps mysql-community-server-8.0.22-1.el7.x86_64

b、删除相关目录,如


#查找mysql相关目录

find / -name mysql

rm -rf /var/lib/mysql /var/lib/mysql/mysql /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /var/log/mysqld.log

安装以及登录

解压tar安装包


tar -xvf mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar

使用yum安装先行依赖包


yum -y install libaio

yum -y install perl

yum -y install net-tools

按顺序安装rpm包


rpm -ivh mysql-community-common-8.0.22-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm  

rpm -ivh mysql-community-libs-8.0.22-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-8.0.22-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-8.0.22-1.el7.x86_64.rpm

查看、启动mysqld服务


systemctl status mysqld

systemctl start mysqld

第一次登录,使用数据库临时密码(必须先启动mysqld服务)


#查找临时密码

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


使用临时密码登录,并设置新密码


登录MySQL:

  mysql -uroot -p

如需使用简单密码(MySQL 8.0不支持):

  set global validate_password_policy=0;

  set global validate_password_length=1;

设置密码:

  alter user 'root'@'localhost' identified by '123456';

  flush privileges;


创建远程登录账号


#MySQL 5.7

grant replication slave on *.* to repl@'192.168.73.%' identified by '123456';

flush privileges;

        

#MySQL 8.0

create user repl@'192.168.73.%' identified  by '123456';

grant all privileges on *.* to repl@'192.168.73.%' with grant option;

flush privileges;

————————————————

版权声明:本文为CSDN博主「路飞的纯白世界」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/u010921136/article/details/112032558