linux安装jdk、tomcat、mysql
linux安装jdk、tomcat、mysql
Linux安装jdk
步骤
mkdir /opt/jdk
- 将压缩包上传到/opt/jdk下
cd /opt/kjdk
- 解压
tar -zxvf jdk-8u261-linux-x64.tar.gz
mkdir /usr/local/java
mv /opt/jdk/jdk1.8.0_261 /usr/local/java
- 配置环境变量的配置文件
vim /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_261
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
让文件生效- 执行
java -version
或which java
检查是否安装成功
安装tomcat
步骤
- 上传安装文件,并解压缩到/opt/tomcat
- 进入解压目录/bin,启动tomcat ./startup.sh
- 开放端口8080
安装mysql
步骤
- 新建文件夹/opt/mysql,并进入该目录
- 上传压缩包到该目录
- 解压,运行
tar -xvf mysql-5.7.36-1.el7.x86_64.rpm-bundle.tar
- centos7自带的mysql数据库是mariadb,会和mysql冲突,要先删除
,运行rpm -qa | grep mari
,查询mariadb相关安装包
- 运行rpm -e --nodeps mariadb-libs删除
运行rpm -e --nodeps marisa - 然后开始真正安装mysql,依次执行以下命令
rpm -ivh mysql-community-common-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.36-1.el7.x86_64.rpm
- 运行
systemctl start mysqld.service
启动mysql - 然后设置root用户密码
mysql自动给root用户设置随机密码,运行grep "password" /var/log/mysqld.log
可看到密码 - 运行
mysql -u root -p
,用root登陆,提示输入密码可用上述的,成功登陆进入命令行 - 设置密码复杂度策略,
set global validate_password_policy=0;
set password for'root'@'localhost'=password('12345678');
- 运行
flush privileges
; 使密码设置生效
License:
CC BY 4.0