基于centos7.9搭建tmall商城
tmall
- 搭建mysql5.7
- 配置jdk
- 启动jar包
搭建mysql5.7
tar -xf mysql-5.7.44-1.el7.x86_64.rpm-bundle.tar -C /opt/
mount /dev/sr0 /mnt/
mv /etc/yum.repos.d/* /media/
cat >> /etc/yum.repos.d/local.repo << EOF
[centos]
name=centos
baseurl=file:///mnt
gpgcheck=0
enabled=1
EOF
rpm -qa | grep -i mysql
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
yum install -y /opt/*
启动数据库
systemctl enable --now mysqld
查看数据库初始密码
[root@node1 ~]# grep 'temporary password' /var/log/mysqld.log
2024-10-28T13:31:59.193948Z 1 [Note] A temporary password is generated for root@localhost: jiU%8Q2gO65G
登录修改密码:因为这个版本的数据库需要使用强密码,所以还需要更低的密码强度要求(不推荐用于生产环境)
mysql -uroot -pjiU%8Q2gO65G
SET GLOBAL validate_password_policy=LOW;
SET GLOBAL validate_password_length=4;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
如果忘记密码了!!!!!,这是第二种方式,第一种成功了可不用管
配置跳过密码验证
vi /etc/my.cnf
skip-grant-tables
启动mysql
systemctl enable --now mysqld
修改密码
mysql -uroot -p
USE mysql;
UPDATE user SET authentication_string=PASSWORD('000000') WHERE user='root';
FLUSH PRIVILEGES;
然后退出,注释掉skip-grant-tables参数,重启即可进入数据库,需要再次修改
[root@localhost ~]# mysql -uroot -p000000
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.7.44
Copyright (c) 2000, 2023, 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>
因为这个版本的数据库需要使用强密码,所以还需要更低的密码强度要求(不推荐用于生产环境)
SET GLOBAL validate_password_policy=LOW;
SET GLOBAL validate_password_length=4;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
创建数据库,并导入脚本
create database tmalldemodb;
use tmalldemodb;
source /root/tmalldemodb.sql
配置jdk
tar -zxvf jdk-8u144-linux-x64.tar.gz -C /usr/local/
配置环境变量
vi /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_144
export PATH=$PATH:$JAVA_HOME/bin
[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包
nohup java -jar tmall-1.0-SNAPSHOT.jar --server.address=0.0.0.0 --server.port=8082 &
界面访问:http://IP:8082/tmall/login
www/12345678abc