Linux安装 Java + MySQL + Redis

下载相关安装包

Java:https://www.oracle.com/java/technologies/javase-downloads.html

Linux安装 Java + MySQL + Redis

关于下载版本,官方给了支持策略:https://www.oracle.com/java/technologies/java-se-support-roadmap.html

Linux安装 Java + MySQL + Redis

MySQL:https://dev.mysql.com/downloads/mysql/

Linux安装 Java + MySQL + Redis

Redis:http://www.redis.cn/

Linux安装 Java + MySQL + Redis

上传到虚拟机

Linux安装 Java + MySQL + Redis

其中MySQL是解压过的

安装Java

解压到指定目录

tar -xvf jdk-8u261-linux-x64.tar.gz -C /usr/local/

修改Source文件

vi /etc/profile

加入配置

# java
export JAVA_HOME=/usr/local/jdk1.8.0_261
export JRE_HOME=/usr/local/jdk1.8.0_261/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

保存并刷新

source /etc/profile

验证

[root@localhost opt]# java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

安装MySQL

验证是否已存在

# 验证mysql

rpm -qa | grep mysql

rpm -e --nodeps mysql

 

# 删除mariadb

rpm -qa | grep mariadb

rpm -e --nodeps mariadb

Linux安装 Java + MySQL + Redis

安装

yum install mysql-community-{server,client,common,libs}-*

输出

[root@localhost opt]# yum install mysql-community-{server,client,common,libs}-*
已加载插件:fastestmirror
正在检查 mysql-community-server-8.0.23-1.el7.x86_64.rpm: mysql-community-server-8.0.23-1.el7.x86_64
mysql-community-server-8.0.23-1.el7.x86_64.rpm 将被安装
正在检查 mysql-community-client-8.0.23-1.el7.x86_64.rpm: mysql-community-client-8.0.23-1.el7.x86_64
mysql-community-client-8.0.23-1.el7.x86_64.rpm 将被安装
正在检查 mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm: mysql-community-client-plugins-8.0.23-1.el7.x86_64
mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm 将被安装
正在检查 mysql-community-common-8.0.23-1.el7.x86_64.rpm: mysql-community-common-8.0.23-1.el7.x86_64
mysql-community-common-8.0.23-1.el7.x86_64.rpm 将被安装
正在检查 mysql-community-libs-8.0.23-1.el7.x86_64.rpm: mysql-community-libs-8.0.23-1.el7.x86_64
mysql-community-libs-8.0.23-1.el7.x86_64.rpm 将被安装
正在检查 mysql-community-libs-compat-8.0.23-1.el7.x86_64.rpm: mysql-community-libs-compat-8.0.23-1.el7.x86_64
mysql-community-libs-compat-8.0.23-1.el7.x86_64.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-client.x86_64.0.8.0.23-1.el7 将被 安装
---> 软件包 mysql-community-client-plugins.x86_64.0.8.0.23-1.el7 将被 安装
---> 软件包 mysql-community-common.x86_64.0.8.0.23-1.el7 将被 安装
---> 软件包 mysql-community-libs.x86_64.0.8.0.23-1.el7 将被 安装
---> 软件包 mysql-community-libs-compat.x86_64.0.8.0.23-1.el7 将被 安装
---> 软件包 mysql-community-server.x86_64.0.8.0.23-1.el7 将被 安装
--> 正在处理依赖关系 net-tools,它被软件包 mysql-community-server-8.0.23-1.el7.x86_64 需要
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
--> 正在检查事务
---> 软件包 net-tools.x86_64.0.2.0-0.25.20131004git.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=================================================================================================================================================
 Package                             架构        版本                             源                                                        大小
=================================================================================================================================================
正在安装:
 mysql-community-client              x86_64      8.0.23-1.el7                     /mysql-community-client-8.0.23-1.el7.x86_64              231 M
 mysql-community-client-plugins      x86_64      8.0.23-1.el7                     /mysql-community-client-plugins-8.0.23-1.el7.x86_64      1.0 M
 mysql-community-common              x86_64      8.0.23-1.el7                     /mysql-community-common-8.0.23-1.el7.x86_64              9.1 M
 mysql-community-libs                x86_64      8.0.23-1.el7                     /mysql-community-libs-8.0.23-1.el7.x86_64                 22 M
 mysql-community-libs-compat         x86_64      8.0.23-1.el7                     /mysql-community-libs-compat-8.0.23-1.el7.x86_64         6.1 M
 mysql-community-server              x86_64      8.0.23-1.el7                     /mysql-community-server-8.0.23-1.el7.x86_64              2.4 G
为依赖而安装:
 net-tools                           x86_64      2.0-0.25.20131004git.el7         base                                                     306 k

事务概要
=================================================================================================================================================
安装  6 软件包 (+1 依赖软件包)

总计:2.6 G
总下载量:306 k
安装大小:2.6 G
Is this ok [y/d/N]: y
Downloading packages:
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm                                                                             | 306 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
** 发现 2 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
2:postfix-2.10.1-9.el7.x86_64 有缺少的需求 libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-9.el7.x86_64 有缺少的需求 libmysqlclient.so.18(libmysqlclient_18)(64bit)
  正在安装    : mysql-community-common-8.0.23-1.el7.x86_64                                                                                   1/7 
  正在安装    : mysql-community-client-plugins-8.0.23-1.el7.x86_64                                                                           2/7 
  正在安装    : mysql-community-libs-8.0.23-1.el7.x86_64                                                                                     3/7 
  正在安装    : mysql-community-client-8.0.23-1.el7.x86_64                                                                                   4/7 
  正在安装    : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                    5/7 
  正在安装    : mysql-community-server-8.0.23-1.el7.x86_64                                                                                   6/7 
  正在安装    : mysql-community-libs-compat-8.0.23-1.el7.x86_64                                                                              7/7 
  验证中      : mysql-community-client-8.0.23-1.el7.x86_64                                                                                   1/7 
  验证中      : mysql-community-libs-compat-8.0.23-1.el7.x86_64                                                                              2/7 
  验证中      : mysql-community-libs-8.0.23-1.el7.x86_64                                                                                     3/7 
  验证中      : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                    4/7 
  验证中      : mysql-community-client-plugins-8.0.23-1.el7.x86_64                                                                           5/7 
  验证中      : mysql-community-server-8.0.23-1.el7.x86_64                                                                                   6/7 
  验证中      : mysql-community-common-8.0.23-1.el7.x86_64                                                                                   7/7 

已安装:
  mysql-community-client.x86_64 0:8.0.23-1.el7 mysql-community-client-plugins.x86_64 0:8.0.23-1.el7 mysql-community-common.x86_64 0:8.0.23-1.el7
  mysql-community-libs.x86_64 0:8.0.23-1.el7   mysql-community-libs-compat.x86_64 0:8.0.23-1.el7    mysql-community-server.x86_64 0:8.0.23-1.el7

作为依赖被安装:
  net-tools.x86_64 0:2.0-0.25.20131004git.el7                                                                                                    

完毕!

下面 启动服务器

systemctl start mysqld

Linux安装 Java + MySQL + Redis

 

登录MySQL

# 获取初始化密码

[root@localhost opt]# cat /var/log/mysqld.log | grep password
# 登录
[root@localhost opt]# mysql -u root -p

# 修改密码

mysql> ALTER USER USER() IDENTIFIED BY 'Abc123-S';

# 退出

mysql> exit;
Bye

Linux安装 Java + MySQL + Redis

因为root账户只能本地登录,所以我们给他新建用户

mysql> CREATE USER 'tom'@'%' IDENTIFIED BY 'Abc123-S';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL ON *.* TO 'tom'@'%';
Query OK, 0 rows affected (0.00 sec)

开启防火墙端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent
systemctl restart firewalld

Navicat连接

Linux安装 Java + MySQL + Redis

 

 

安装Redis

解压到当前文件夹

tar -xvf redis-6.0.6.tar.gz 

安装gcc(因为centos默认安装4.8.5版本的,不满足需要)

yum install centos-release-scl
yum install devtoolset-8-gcc*
echo "source /opt/rh/devtoolset-8/enable" >>/etc/profile
source /etc/profile
# 查看版本
gcc -v
gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)

进入redis目录

cd redis-6.0.6/

执行make命令

make MALLOC=libc/jemalloc

然后install

make install

Linux安装 Java + MySQL + Redis

 

这个默认在/usr/local/bin目录生成服务器文件

Linux安装 Java + MySQL + Redis

 

修改redis配置文件

vi /opt/redis-6.0.6/redis.conf

bind 192.168.28.128

daemonize yes

绑定地址,以及后台启动

启动

./redis-server /opt/redis-6.0.6/redis.conf

Linux安装 Java + MySQL + Redis

 本地连接测试

Linux安装 Java + MySQL + Redis

 

上一篇:Linux下安装mysql


下一篇:cetnos7安装mysql5.7