Centos7 从JDK到Mysql到TOMCAT 部署

YUM安装MYSQL

查看yum是否安装过mysql

yum list installed mysql*

如或显示了列表,说明系统中有MySQL
Centos7 从JDK到Mysql到TOMCAT 部署_第1张图片

  • yum卸载
    根据列表上的名字
yum remove mysql-community-client mysql-community-common mysql-community-libs >mysql-community-libs-compat mysql-community-server mysql57-community-release
rm -rf /var/lib/mysql  
rm /etc/my.cnf
  • rpm查看安装
rpm -qa | grep -i mysql

Centos7 从JDK到Mysql到TOMCAT 部署_第2张图片

  • rpm 卸载
rpm -e mysql57-community-release-el7-9.noarch
rpm -e mysql-community-server-5.7.17-1.el7.x86_64
rpm -e mysql-community-libs-5.7.17-1.el7.x86_64
rpm -e mysql-community-libs-compat-5.7.17-1.el7.x86_64
rpm -e mysql-community-common-5.7.17-1.el7.x86_64
rpm -e mysql-community-client-5.7.17-1.el7.x86_64
cd /var/lib/  
rm -rf mysql/
  • 清除余项
whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/local/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
#删除上面的文件夹
rm -rf /usr/bin/mysql
  • 删除配置
rm –rf /usr/my.cnf
rm -rf /root/.mysql_sercret
  • 剩余配置检查
chkconfig --list | grep -i mysql
chkconfig --del mysqld
  • 安装MYSQL
wget http://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm
sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm

接下来使用yum安装
更新yum软件包

yum check-update  

更新系统

yum update

安装mysql

yum install mysql mysql-server

安装完成以后运行mysql并登录mysql

systemctl start mysqld
mysql -u root -p

输入密码
登陆成功,查看自动生成的密码

grep "password" /var/log/mysqld.log
或
grep "temporary password" /var/log/mysqld.log

安装后首次启动服务后执行初始化向导

$ mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: 初始化密码
The existing password for the user account root has expired. Please set a new >password.

**重置初始密码**
New password: 再次确认密码
Re-enter new password: 再次确认密码
是否是对 root 设置密码: y
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password: 再次确认密码
Re-enter new password: 再次确认密码
是否使用提供的密码策略: y
Do you wish to continue with the password provided?(Press y|Y for Yes, any other
key for No) : y
是否移除匿名用户: y
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
默认情况下,MySQL安装有匿名用户 允许任何人登录MySQL而不需要 为他们创建的用>户帐户
这是专为测试,并使安装更加顺利。 在进入生产环境之前,您应该删除它们 环境
是否禁用远程登录: n
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
是否删除测试数据: y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) :y
 是否刷新权限表: y
 Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
 All done!
  • 开启远程连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
FLUSH PRIVILEGES;
  • 修改密码
update mysql.user set authentication_string=password('123456') where user='root' and host='localhost';  
或
show databases;
update user set authentication_string=password("123456") where user="root";
或
SET password='密码';
  • 修改密码策略
设置密码的验证强度等级
set global validate_password_policy=LOW;       

设置密码的长度
set global validate_password_length=6; 

安装JDK

yum -y list java*   --查看yum的jdk安装包
yum  install  java-1.8.0-openjdk   java-1.8.0-openjdk-devel --安装JDK,如果没有java-1.8.0-openjdk-devel就没有javac命令 
也可用 yum install java-1.8.0-openjdk* 安装所有java1.8.0所有Java程序

配置环境变量

通过yum默认安装的路径为 /usr/lib/jvm
/usr/lib/jvm
ls -la

vi /etc/profile

在文件最后加入如下行

    JAVA_HOME=/usr/lib/jvm/java
    PATH=$PATH:$JAVA_HOME/bin
    CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    export JAVA_HOME CLASSPATH PATH

保存退出:wq

验证

java -version 
javac -version

jdk1.8安装成功

下载tomcat地址去官方复制

wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.37/bin/apache-tomcat->8.5.37.tar.gz
下载完成后
tar -zxvf apache-tomcat-8.5.37.tar.gz   解压
完成

Centos7 防火墙打开端口号

firewall-cmd --zone=public --add-port=3306/tcp --permanent
–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
firewall-cmd --list-ports #查看已经开放的端口
firewall-cmd --reload #重启firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示		notrunning,开启后显示running)    
开放以后需要重启防火墙

你可能感兴趣的:(linux,Contos部署)