上线的代码有两种方式:
第一种方式是直接将程序目录放在webapps目录下面。
第二种方式是使用开发工具将程序打包成war包,然后上传到webapps目录下面。
修改内容如下 #关闭8.0版本,开启5.7版本
安装mysql
[root@java-tomcat1 yum.repos.d]# yum -y install mysql-server mysql [root@java-tomcat1 yum.repos.d]# cd [root@java-tomcat1 ~]# systemctl start mysqld [root@java-tomcat1 ~]# systemctl enable mysqld **查找密码并修改密码** [root@java-tomcat1 ~]# grep pass /var/log/mysqld.log #过滤查找密码 2019-07-05T15:57:15.294365Z 1 [Note] A temporary password is generated for root@localhost: %6yx817IeX-J [root@java-tomcat1 ~]# mysqladmin -u root -p'%6yx817IeX-J' password 'QianFeng@123' #修改密码配置数据库
[root@java-tomcat1 ~]# mysql -u root -p'QianFeng@123' mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.26 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database jspgou default charset=utf8; #创建数据库设置字符集为utf-8 Query OK, 1 row affected (0.00 sec) mysql> \q Bye上传jspgou商城的代码
[root@java-tomcat1 ~]# unzip jspgouV6.1-ROOT.zip [root@java-tomcat1 ~]# cp -r ROOT/ /usr/local/tomcat/webapps/ [root@java-tomcat1 ~]# cd /usr/local/tomcat/webapps/ [root@java-tomcat1 webapps]# ls ROOT [root@java-tomcat1 webapps]# vim ROOT/WEB-INF/config/jdbc.properties#添加上数据库密码,即可
配置数据库连接----jdbc
将数据导入数据库: [root@java-tomcat1 ~]# cd DB/ [root@java-tomcat1 DB]# ls jspgou.sql [root@java-tomcat1 DB]# mysql -uroot -p'QianFeng@123' -D jspgou < jspgou.sql **DB中的sql数据库文件导入到数据库中** mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1067 (42000) at line 97: Unknown error 1067 **若出现上面的报错,无法导入,可以先添加下面的参数,然后再次导入即可** [root@java-tomcat1 DB]# vim /etc/my.cnf ----添加sql_mod sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUB explicit_defaults_for_timestamp=1 [root@java-tomcat1 DB]# systemctl restart mysqld [root@java-tomcat1 DB]# mysql -uroot -p'QianFeng@123' -D jspgou < jspgou.sql 启动tomcat访问: [root@java-tomcat1 ~]# /usr/local/tomcat/bin/startup.sh #启动tomcat [root@java-tomcat1 ~]# netstat -lntp #查看tomcat端口信息访问:http://192.168.1.7:8080/