mall
- 搭建数据库
- 配置Java
- 配置jar包
一款模仿天猫的在线购物网站,基于centos7.9搭建
搭建数据库
官网下载软件包后上传
基于centos7.9搭建mysql5.6.42
[root@mysql02 ~]# ls
anaconda-ks.cfg init.sh MySQL-5.6.42-1.el7.x86_64.rpm-bundle.tar
解压
tar -xf MySQL-5.6.42-1.el7.x86_64.rpm-bundle.tar -C /opt/
[root@mysql02 ~]# ls /opt/
MySQL-client-5.6.42-1.el7.x86_64.rpm MySQL-server-5.6.42-1.el7.x86_64.rpm MySQL-test-5.6.42-1.el7.x86_64.rpm
MySQL-devel-5.6.42-1.el7.x86_64.rpm MySQL-shared-5.6.42-1.el7.x86_64.rpm
MySQL-embedded-5.6.42-1.el7.x86_64.rpm MySQL-shared-compat-5.6.42-1.el7.x86_64.rpm
检测是否有其他版本mysql,否则卸载
rpm -qa | grep -i mysql
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
使用yum进行安装,注意搭配centos源
mount /dev/sr0 /mnt/
mv /etc/yum.repos.d/* /home/
cat > /etc/yum.repos.d/c.repo <<eof
[c]
name=c
baseurl=file:///mnt
gpgcheck=0
enabled=1
eof
[root@mysql02 ~]# yum clean all;yum repolist
Loaded plugins: fastestmirror
Cleaning repos: c
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror
Determining fastest mirrors
c | 3.6 kB 00:00:00
(1/2): c/group_gz | 153 kB 00:00:00
(2/2): c/primary_db | 3.3 MB 00:00:00
repo id repo name status
c c 4,070
repolist: 4,070
[root@mysql02 ~]#
yum install -y /opt/*
配置my.cnf,并且需要跳过验证,设置密码,或者命令也可,二者选一
使用命令方式需要在数据库停止状态下使用,然后新开一个窗口进入数据库
mysqld_safe --skip-grant-tables &
新开窗口执行
mysql -uroot -p
USE mysql;
UPDATE user SET password=PASSWORD('123456') WHERE user='root';
FLUSH PRIVILEGES;
关闭mysqld_safe --skip-grant-tables &启动窗口后重启
systemctl restart mysql
mysql -uroot -p123456
SET PASSWORD = PASSWORD('123456');
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
关闭防火墙和selinux
setenforce 0
systemctl stop firewalld
即可测试远程访问
PS C:\Users\huhy> mysql -h 192.168.200.100 -uroot -123456
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 2
Server version: 5.6.42 MySQL Community Server (GPL)
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
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>
上传sql脚本加载
mysql -uroot -p123456 -e 'source /root/tmalldemodb.sql;'
配置Java
下载jdk1.8,然后上传到centos上
```python
[root@localhost ~]# ls jdk-8u144-linux-x64.tar.gz
jdk-8u144-linux-x64.tar.gz
解压到
mkdir -p /usr/local/java
tar -zxvf jdk-8u144-linux-x64.tar.gz -C /usr/local/java/
配置环境变量
vi /etc/profile
export JAVA_HOME=/usr/local/java/1.8.0_144
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
ln -s /usr/local/java/jdk1.8.0_144/bin/java /usr/bin/java
[root@localhost ~]# source /etc/profile
[root@localhost ~]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
[root@localhost ~]#
配置jar包
yum install -y unzip
yum install -y zip
上传TmallDemo.jar
mkdir -p /u01/apps/mall
cd /u01/apps/mall
mv TmallDemo.jar .
编辑配置文件
vim TmallDemo.jar
找到并修改BOOT-INF/classes/application-prod.yml
修改BOOT-INF/classes/application.yml,dev修改为prod
启动jar包
nohup java -jar TmallDemo.jar >/dev/null 2>/dev/null &
前端访问:IP:8082/tmall
注册页面
登录页面
购物界面