文章

linux安装jdk、tomcat、mysql

linux安装jdk、tomcat、mysql

Linux安装jdk

步骤

  1. mkdir /opt/jdk
  2. 将压缩包上传到/opt/jdk下
  3. cd /opt/kjdk
  4. 解压 tar -zxvf jdk-8u261-linux-x64.tar.gz
  5. mkdir /usr/local/java
  6. mv /opt/jdk/jdk1.8.0_261 /usr/local/java
  7. 配置环境变量的配置文件 vim /etc/profile
  8. export JAVA_HOME=/usr/local/java/jdk1.8.0_261
    export PATH=$JAVA_HOME/bin:$PATH
  9. source /etc/profile 让文件生效
  10. 执行java -versionwhich java检查是否安装成功

安装tomcat

步骤

  1. 上传安装文件,并解压缩到/opt/tomcat
  2. 进入解压目录/bin,启动tomcat ./startup.sh
  3. 开放端口8080

安装mysql

步骤

  1. 新建文件夹/opt/mysql,并进入该目录
  2. 上传压缩包到该目录
  3. 解压,运行tar -xvf mysql-5.7.36-1.el7.x86_64.rpm-bundle.tar
  4. centos7自带的mysql数据库是mariadb,会和mysql冲突,要先删除
    ,运行rpm -qa | grep mari,查询mariadb相关安装包

35.1.png

  1. 运行rpm -e --nodeps mariadb-libs删除
    运行rpm -e --nodeps marisa
  2. 然后开始真正安装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
  1. 运行systemctl start mysqld.service 启动mysql
  2. 然后设置root用户密码
    mysql自动给root用户设置随机密码,运行grep "password" /var/log/mysqld.log可看到密码
  3. 运行mysql -u root -p,用root登陆,提示输入密码可用上述的,成功登陆进入命令行
  4. 设置密码复杂度策略,set global validate_password_policy=0;
  5. set password for'root'@'localhost'=password('12345678');
  6. 运行flush privileges; 使密码设置生效

笔记来源于:https://www.bilibili.com/video/BV1Sv411r7vd?p=90

License:  CC BY 4.0