Linux CentOS 服务器配置 MySql、Tomcat

可能用到的命令

  1. 查看系统信息:cat /etc/redhat-release
  2. 查看安装包:yum list xx*
  3. 查看文件大小:du -h xxxdu -b xxx
  4. 从服务器上下载文件:scp username@servername:/remote_dir/filename local_dir
  5. 上传本地文件到服务器:scp local_path/filename username@servername:remote_path
  6. 从服务器下载整个目录:scp -r username@servername:/remote_dir/ local_dir
  7. 上传目录到服务器:scp -r local_dir username@servername:remote_dir

安装环境

JDK

  1. 查看jdk列表:yum list java*
  2. 安装特定版本:yum -y install java-1.8.0-openjdk
  3. 查看安装结果:java -v

MySql

安装

  1. 查看系统版本
$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
  1. 下载对应的YUM https://dev.mysql.com/downloads/repo/yum/
$ wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
  1. 安装MySql源
$ sudo rpm -Uvh mysql80-community-release-el8-1.noarch.rpm
  1. 检查是否安装成功

    执行成功后会在/etc/yum.repos.d/目录下生成两个repo文件mysql-community.repo及 mysql-community-source.repo,并且通过yum repolist可以看到mysql相关资源
$ yum repolist enabled | grep "mysql.*-community.*"
!mysql-connectors-community/x86_64 MySQL Connectors Community                108
!mysql-tools-community/x86_64      MySQL Tools Community                      90
!mysql80-community/x86_64          MySQL 8.0 Community Server                113
  1. 安装MySql

    下载比较慢
$ sudo yum install mysql-community-server

修改密码

$ ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxxxxxx

开启远程访问<8.0

$ grant all privileges on *.* to 'root'@'%' identified by '你的密码' with grant option

开启远程访问>=8.0

  1. $ CREATE USER 'root'@'%' IDENTIFIED BY 'pWVRIVJw3NJX%%lB';
  2. $ GRANT ALL ON *.* TO 'root'@'%';
  3. $ ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxxxx
  4. $ FLUSH PRIVILEGES;

Tomcat

  1. 现在本地下载Tomcat安装包
  2. 上传到server
  3. 解压安装包
  4. 配置环境变量:
# Tomcat
export TOMCAT_HOME=/usr/local/apache-tomcat-9.0.35
export PATH=$TOMCAT_HOME/bin:$PATH
  1. 增加域名解析conf/server.xml中Host节点添加新的Host
    
        app.easyplan.cloud
        
        
    
  1. 启动:bin/start.sh

你可能感兴趣的:(Linux CentOS 服务器配置 MySql、Tomcat)