1. Linux环境中配置JDK
2. Linux环境中配置Tomcat
3. Linux环境中配置mariadb
注意:Linux下的安装过程需要以root用户身份进行操作
1. Linux环境中配置JDK
Linux环境下配置JDK最简单的办法就是基于yum进行安装, 安装过程:
-
使用 yum list | grep JDK 命令查看yum中所有的JDK版本
-
找到java-1.8版本的带有devel和x86_64后缀的安装包, Ctrl + Insert复制版本号((java-1.8.0-openjdk-devel.x86_64))
-
在命令行输入yum install, 并通过Shift + Insert 快捷键将复制好的JDK版本粘贴在Install后面, 按下回车, 系统提示是否确认下载? 按下" y "即可进行下载.
-
下载好之后,在命令行输入javac, 结果类似以下字样即代表下载成功:
2. Linux环境中配置Tomcat
yum中虽然存在Tomcat, 但是版本太低, 而Tomcat版本需要和JDK版本匹配, 因此, 我们可以将Windows环境下的Tomcat传输给Linux.
-
在Windows环境中进入Tomcat官网:Apache Tomcat - Welcome!
-
点击左侧的Tomcat 8:
-
下载Core选项中的zip:
-
下载好之后, 将下载好的文件拖动到XShell中(注意:拖动的是zip文件)
-
在Linux环境中通过命令unzip 文件名来对zip文件解压缩
-
移动到解压好的Tomcat目录的bin目录下, 通过命令:chmod +x *.sh 来为所有的.sh文件加上可执行权限
-
配置完成, 通过命令: sh startup.sh启动Tomcat
启动成功!
3. Linux环境中配置mariadb
执行安装操作:
安装 mariadb 服务
命令: yum install -y mariadb-server
安装mariadb 命令行客户端
命令: yum install -y mariadb
安装 mariadb C library
命令: yum install -y mariadb-libs
安装 mariadb 开发包
命令: yum install -y mariadb-devel
更改配置文件
- 使用命令 cd /etc/my.cnf.d/移动到指定目录
- 使用命令 vim client.cnf 打开client.cnf文件, 此时处于普通模式, 不能修改文件
- 按下 i 键进入插入模式
- 在[client] 输入: default-character-set=utf8
结果类似于以下内容:
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#
[client]
default-character-set = utf8
# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
- 按下esc返回普通模式. 输入 :wq 保存并退出(注意输入的是冒号wq)
- 重复2~5步, 通过 vim mysql-clients.cnf 打开mysql-clients.cnf文件, 并在[mysql] 下添加 default-character-set=utf8
结果类似于以下内容:
#
# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#
[mysql]
default-character-set = utf8
[mysql_upgrade]
- 重复2~5步, 通过 vim server.cnf 打开server.cnf文件, 在[mysqld]下添加以下内容:
collation-server = utf8_general_ci
init-connect=‘SET NAMES utf8’
character-set-server = utf8
sql-mode = TRADITIONAL
最终结果类似于:
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
sql-mode = TRADITIONAL
# this is only for embedded server
启动
启动mariadb服务:
systemctl start mariadb
设置开机自启动
systemctl enable mariadb
查看服务状态
systemctl status mariadb
结果:
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2022-07-03 12:17:21 CST; 21s ago
Main PID: 6619 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─6619 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─6857 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/my...
使用命令行客户端尝试连接
mysql -uroot
结果:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
启动成功!
The End!
文章评论