ssh 远程连接服务器
ssh -p22 user@49.233.186.242 #用户名@公网地址
passwd :
上传文件
scp /path/filename username@servername:/path ;# 直接使用没有权限
暴露服务器端口是外部可以访问
连接服务器上的数据库
用ping 测试服务器的网络是否正常
运行代码时候查看服务器的报错
进入tomcat/logs/文件夹下 tail -f catalina.out
http://49.233.186.242/spring/main
在服务器端授权数据库可以远程连接
# 进入mysql数据库
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
## springboot 连接远程服务器的数据库
#端口号配置
server:
port: 8080
spring:
#模板引擎配置
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: HTML
encoding: UTF-8
cache: false
servlet:
content-type: text/html
#静态文件配置
resources:
static-locations: classpath:/static/,classpath:/META-INF/resources,classpath:/templates/
#jdbc配置jdbc:mysql://localhost:3306
datasource:
url: jdbc:mysql://49.233.186.242:3389/db1?useUnicode=true&characterEncoding=utf8&useSSL=false
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
#mybatis配置
mybatis:
#映射文件路径
mapper-locations: classpath:mapper/*.xml,classpath:generator/*.xml
#模型所在的保命
type-aliases-package: com.yt.springtest.model