CentOS安装Mysql步骤

CentOS安装Mysql步骤

  1. 下载wget命令

    yum -y install wget
    
  2. 在线下载安装包

    wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
    
  3. 安装Mysql

    rpm -ivh mysql57-community-release-el7-8.noarch.rpm
    
  4. 安装MySQL服务(这个过程比较慢,耐心等待)

    cd /etc/yum.repos.d/
    
    yum -y install mysql-server
    
  5. 启动MySQL服务

    systemctl start mysqld.service
    #或
    systemctl start mysqld
    
  6. 查找默认密码

    grep "password" /var/log/mysqld.log
    
  7. 使用默认密码登录

    mysql -uroot -p
    
  8. 更改密码时,如果想降低密码的复杂度优先执行此步骤。

    #密码校验强度降低为低风险
    set global validate_password_policy=LOW;
    #修改设置密码的长度
    set global validate_password_length=6;
    
    
  9. 更改密码

    ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; 
    
    #退出MySQL
    exit;
    
    

到此步,MySQL已顺利安装完成,接下来配置远程访问MySQL

  1. 执行以下命令开启远程访问限制 (在MySQL中执行)

    #192.168.0.1换成自己的IP地址,password为设置MySQL远程登录的密码
    grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;
    
    
  2. 开启防火墙,但防火墙添加开放端口3306

    #开启防火墙
    systemctl start firewalld.service
    # 开放3306端口
    firewall-cmd --zone=public --add-port=3306/tcp --permanent 
    
    #配置立即生效
    firewall-cmd --reload
    
    ####如有需要,关闭某个端口
    #关闭3306端口
    firewall-cmd --zone=public --remove-port=3306/tcp --permanent 
    
    #查看防火墙状态
     firewall-cmd --state
    
    

好的教程:

  1. https://blog.csdn.net/weixin_42140801/article/details/107859925?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522162925229016780269871176%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=162925229016780269871176&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2alltop_positive~default-1-107859925.first_rank_v2_pc_rank_v29&utm_term=centos7%E5%AE%89%E8%A3%85mysql&spm=1018.2226.3001.4187

  2. https://blog.csdn.net/Bb15070047748/article/details/106245223?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522162925229016780269871176%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=162925229016780269871176&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2alltop_positive~default-2-106245223.first_rank_v2_pc_rank_v29&utm_term=centos7%E5%AE%89%E8%A3%85mysql&spm=1018.2226.3001.4187

上一篇:Strategic Game(匈牙利算法,最小点覆盖数)


下一篇:HTML5规范的本地存储