在ubuntu上部署ssm web项目
在ubuntu上部署ssm web项目
安装mysql
sudo apt-get install mysql-serversudo apt-get install mysql-commonsudo apt-get install mysql-client
实现远程链接服务器上的MySQL数据库
在阿里云中添加安全组
开放3306、80端口
初始化MySQL(MySQL 5.7并未设置默认密码,需要初始化,即运行安全向导)
sudo mysql_secure_installation
安全向导:
1.(是否设置随机密码,Y/y随机密码, N/n自己输入密码)
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (我的选项)
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入)
2.(是否删除匿名用户,建议删除)
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No)
3.(是否禁止root账户远程登陆,建议禁止)
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No)
4.(是否删除test数据库,建议删除)
By default, MySQL comes with a database named 'test' that
anyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No)
5.(是否重新加载权限表,应该重新加载)
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
修改配置文件
将bind-address改为*
或0.0.0.0
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
使用CTRL+X
保
存并退出 nano 编辑器
- 重启mysql服务
sudo systemctl restart mysql
将用作远程登录的账号host改为任意主机或固定ip
添加所有IP都可以访问的用户:
grant all privilege on *.* to '用户名'@'%' identified by '密码' with grant option;
或者也可以给root用户设置为所有ip都可访问:
update user set host='%' where user='root' and host='localhost';
刷新权限:
flush privileges;
查看用户权限:
select host,user from user;
本地数据库迁移(可能出现编码问题)
服务器安装JDK
-
通过xshell传输jdk到
usr/local/
目录下 -
解压jdk
tar -zxvf jdk-15.0.2_linux-x64_bin.tar.gz
-
删除jdk压缩包
rm -f jdk-15.0.2_linux-x64_bin.tar.gz
-
将jdk配置到
/etc/profile
vim /etc/profile
-
按
i
进入编辑, 在文件尾部添加- jdk11以上没有jre
JAVA_HOME=/usr/local/jdk-15.0.2CLASSPATH=.:${JAVA_HOME}/bin.tools.jarPATH=${JAVA_HOME}/bin:${PATH}export JAVA_HOME CLASSPATH PATHexport JRE_HOME=${JAVA_HOME}
- jdk11以下
export JAVA_HOME=/usr/local/jdk-15.0.2export JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:${JAVA_HOME}export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/binexport PATH=$PATH:${JAVA_PATH}
-
esc
-->:wq
保存并退出
-
-
javac
/java -version
测试是否安装成功
安装tomcat
-
通过xshell传输tomcat到
usr/local/
目录下 -
解压jdk
tar -zxvf apache-tomcat-8.5.73.tar
-
删除jdk压缩包
rm -f apache-tomcat-8.5.73.tar
-
重命名
mv apache-tomcat-8.5.73.tar tomcat8
-
将jdk配置到
/etc/profile
vim /etc/profile
部署web
- 将war包放入
/usr/local/tomcat8/webapps/
目录下
启动tomcat服务器
- 通过
/usr/local/tomcat8/bin/startup.sh
启动tomcat服务器 - 通过
/usr/local/tomcat8/bin/startup.sh
关闭服务器 - 已经将端口号改为80
问题
-
localhost无法访问MySQL : 可能是mysql版本升级 密码格式改变,需要设置成mysql native_password
-
表单中文提交乱码: 数据库编码格式有误
-
进入数据库查询当前编码格式:
show variables like '%character%';
-
更改默认编码:
vi /etc/mysql/mysql.conf.d/mysqld.cnf
添加编码格式:
-
重启数据库
systemctl restart mysql
-
查询当前编码格式:
-
作者:霹雳猪猪
来源链接:https://www.cnblogs.com/plzz/p/15758560.html
版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。
2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。