• CentOs7通过yum安装mysql和tomcat


    安装mysql

    安装YUM Repo

    //由于CentOS 的yum源中没有mysql,需要到mysql的官网下载yum repo配置文件。
    wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
    
    //repo的安装
    rpm -ivh mysql57-community-release-el7-9.noarch.rpm
    

    安装MySQL

    yum install mysql-server
    

    启动msyql

    systemctl start  mysqld.service
    

    查看mysql运行状态

    systemctl status mysqld.service
    
    [root@localhost mysql]# systemctl status mysqld.service
    ● mysqld.service - MySQL Server
    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
    Active: active (running) since Tue 2019-08-27 18:53:48 CST; 17s ago
        Docs: man:mysqld(8)
            http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 3827 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
    Process: 3744 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
    

    获取mysql安装时的临时密码

    grep 'temporary password' /var/log/mysqld.log
    
    [root@localhost mysql]# grep 'temporary password' /var/log/mysqld.log
    2019-08-27T10:53:41.774424Z 1 [Note] A temporary password is generated for root@localhost: aP=hPefJR84g
    

    登录mysql

    mysql -u root -p  //注意,按回车键后输入上述显示的临时密码,在密码输入时密码框不会发生任何变化,密码输入完成后点击回车,即可成功进入mysql
    
    [root@localhost mysql]# mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.27
    

    修改登录密码

    mysql安装进入后必须先修改密码,不修改密码进行任何操作都会报错Your password does not satisfy the current policy requirements
    刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
    如果你想要设置一个简单的测试密码的话,比如设置为123456,会提示这个错误,报错的意思就是你的密码不符合要求
    mysql> alter user 'root'@'localhost' identified by '123456';
          ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    
    解决方案:
    1. 修改validate_password_policy参数的值
    mysql> set global validate_password_policy=0;
          Query OK, 0 rows affected (0.00 sec)
    2.validate_password_length(密码长度)参数默认为8,修改为1
    mysql> set global validate_password_length=1;
           Query OK, 0 rows affected (0.00 sec)
    3.再次设置新的密码为简单密码即可成功
    例如,设置为123456
    mysql> alter user 'root'@'localhost' identified by '123456';
           Query OK, 0 rows affected (0.00 sec)
    //设置修改的密码永不过期
    mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
           Query OK, 0 rows affected (0.00 sec)
    

    mysql开启关闭

    systemctl stop mysqld #关闭MySQL
    systemctl restart mysqld #重启MySQL
    systemctl status mysqld #查看MySQL运行状态
    systemctl enable mysqld #设置开机启动
    systemctl disable mysqld #关闭开机启动
    

    mysql远程访问设置

    grant all privileges on *.* to 'root' @'%' identified by 'root';
    
    flush privileges; //刷新内容
    
    mysql> grant all privileges on *.* to 'root' @'%' identified by 'root';
          Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> flush privileges;
          Query OK, 0 rows affected (0.00 sec)
    

    安装tomcat

    // 安装tomcat
    [root@localhost ~]# yum -y install tomcat
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
    * base: mirrors.huaweicloud.com
    * extras: mirrors.aliyun.com
    * updates: mirrors.aliyun.com
    Resolving Dependencies
    --> Running transaction check
    
    //检测tomcat是否安装成功
    [root@localhost ~]# rpm -q tomcat
    tomcat-7.0.76-9.el7_6.noarch
  • 相关阅读:
    删除难以删除的文件
    DLL创建与使用
    Springboot多文件上传
    解决javaweb项目启动端口号被占用
    pl/sql 导出数据库表dmp文件并导入数据库过程
    Spring Boot 静态资源处理
    Consider defining a bean of type错误
    SpringBoot+layUI上传图片功能
    jQuery改变html页面样式
    Springboot启动后默认访问页面修改
  • 原文地址:https://www.cnblogs.com/gujun1998/p/11420513.html
Copyright © 2020-2023  润新知