当前位置:网站首页>【Linux】——使用xshell在Linux上安装MySQL及实现Webapp的部署
【Linux】——使用xshell在Linux上安装MySQL及实现Webapp的部署
2022-06-28 05:10:00 【同学潘】
引言:
在上篇文章中已经为大家介绍了使用xshell在Linux上安装JDK、Tomcat️使用xshell在Linux上安装JDK、Tomcat,接下来就让我们再一起学习如何使用xshell在Linux上安装MySQL及实现Webapp的部署吧
仅针对博主之前写的博客系统来进行博客系统——前后端分离
安装MySQL
由于网上很多的安装教程都是通过手动编译源码安装的,比较麻烦,所以我们用的是yum直接安装,不仅方便而且不易出错
以下操作都以 root 用户进行操作
使用yum安装
安装 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
一般来说只要第一个和第四个安装成功就没啥问题了
更改配置
- 更改 /etc/my.cnf.d/client.cnf 文件
[client] 下加一行配置 default-character-set=utf8
vim /etc/my.cnf.d/client.cnf
然后输入 i 进入插入模式,在[client] 下加一行配置 default-character-set=utf8
之后按下Esc键切换到normal模式,并输入 :wq 保存退出
最终内容
- 更改 /etc/my.cnf.d/mysql-clients.cnf 文件
[mysql] 下加一行配置 default-character-set=utf8
vim /etc/my.cnf.d/mysql-clients.cnf
然后进入到插入模式,在[mysql] 下加一行配置 default-character-set=utf8
之后按下Esc键切换到normal模式,并输入 :wq 保存退出
最终内容
- 更改 /etc/my.cnf.d/server.cnf 配置
[mysqld] 下加配置
collation-server = utf8_general_ci
init-connect=‘SET NAMES utf8’
character-set-server = utf8
sql-mode = TRADITIONAL
vim /etc/my.cnf.d/server.cnf
然后进入到插入模式,在[mysqld] 下加配置(一定要确保每个字母都正确,并且单引号是在英文状态下的)
collation-server = utf8_general_ci
init-connect=‘SET NAMES utf8’
character-set-server = utf8
sql-mode = TRADITIONAL
之后按下Esc键切换到normal模式,并输入 :wq 保存退出
最终内容
启动
启动服务
systemctl start mariadb
设置服务开启自启动
systemctl enable mariadb
查看服务状态
systemctl status mariadb
可能的输出为,注意到 Active 状态为 active (running)
测试连接
使用命令行客户端尝试连接
mysql -uroot
可能的输出为:
查看 mariadb 版本号——select version();
查看字符集配置——show variables like ‘%char%’;
目前我们的 mariadb 用户是没有密码的,是非常不安全的,所以可以执行以下步骤来设置密码:
# mysql_secure_installation
选择 Y/N 的时候都选 Y
在New password:
Re-enter new password:
时设置你自己的 root 密码
然后会出现下面的情况:
使用命令行客户端尝试连接(带密码)
# mysql -uroot -p
随后输入你刚才设置的密码,可能的输出为:
实现Webapp的部署
要想把项目给部署到云服务器上,需要给服务器上准备好依赖的数据,在云服务器的数据库上完成建库建表的操作,并且导入一些数据。我们把之前db.sql里面的数据粘贴过来就行。
如果在Linux中你的 mariadb 用户是没有密码的,那么你这里也要设置为空:
重新打包,我们需要基于maven的package操作来生成war包,双击package即可。
在进行打包前,可以先在pom.xml中配置一下打包的类型和包的名字
出现下面这种情况就说明我们的包打好了️
接下来上传到服务器上,最简单的方法就是一个字:拖
首先找到我们之前所下载的那个tomcat,并进入webapps目录,然后拖进去就行了
在上篇文章提到过,直接往xshell中拖拽即可,拖拽依赖了一个rz这样的命令,如果机器上没装rz,就拖不了
tomcat如果在运行中的话,就会自动对war进行解压缩
接下来我们就可以进行验证了:

至此,就已经成功的把之前的项目成功的部署到服务器上了
边栏推荐
- Metartc5.0 API programming guide (I)
- Study on chemical properties and technology of biovendor rage ELISA Kit
- 深度强化学习笔记
- Feign implements path escape through custom annotations
- PCR/qPCR研究:Lumiprobe丨dsGreen 用于实时 PCR
- The short video local life section has become popular. How to grasp the new opportunities?
- 刘海屏手机在部分页面通过[[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom得到底部安全区高度为0问题
- Deeplearning ai-week1-quiz
- Interview: what are the similarities and differences between abstract classes and interfaces?
- quartus 复制IP核
猜你喜欢

Learning Tai Chi Maker - mqtt Chapter 2 (V) heartbeat mechanism

基于微信小程序的婚纱影楼门户小程序

2022年安全员-B证考试题库及答案

改性三磷酸盐研究:Lumiprobe氨基-11-ddUTP

Latest Windows version 5.0.14 of redis

二级造价工程师证书含金量到底有多高?看这些就知道了

Lumiprobe cell imaging analysis: PKH26 cell membrane labeling kit

PCR/qPCR研究:Lumiprobe丨dsGreen 用于实时 PCR

metaRTC5.0编程之p2p网络穿透(stun)指南

【牛客网刷题系列 之 Verilog快速入门】~ 四选一多路器
随机推荐
[microservices openfeign] openfeign quick start service invocation based on feign
高通平台 Camera 之 MCLK 配置
通过例子学习Rust
C语言中函数是什么?编程中的函数与数学中的函数区别?理解编程语言中的函数
Carboxylic acid study: lumiprobe sulfoacyanine 7 dicarboxylic acid
2022西式面点师(高级)考试试题模拟考试平台操作
[skywalking] learn distributed link tracking skywalking at one go
Qcom LCD commissioning
深度强化学习笔记
Sqlmap tool user manual
刘海屏手机在部分页面通过[[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom得到底部安全区高度为0问题
Biovendor sRAGE antibody solution
[Verilog quick start of Niuke online question brushing series] ~ one out of four multiplexer
What are functions in C language? What is the difference between functions in programming and functions in mathematics? Understanding functions in programming languages
Reactive dye research: lumiprobe af594 NHS ester, 5-isomer
短视频本地生活版块成为热门,如何把握新的风口机遇?
Learning Tai Chi Maker - mqtt Chapter II (VI) mqtt wills
PCR/qPCR研究:Lumiprobe丨dsGreen 用于实时 PCR
Dart learning - functions, classes
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案