虚拟机Centos7安装Mysql

  1. 虚拟机安装Centos7不多介绍,太多的文章可以参考了,这里主要记下安装MySql的过程。
  2. 登录Centos系统,并保证是以root用户登陆的。
  3. 安装wget
    yum install wget
    
  4. 查看一下系统版本
    cat /etc/centos-release
    
  5. 下载mysql安装包(以下地址对应的是Centos7)
    wget http://repo.mysql.com/mysql57-community-release-el7.rpm 
    
  6. 安装下载的rpm
    rpm -ivh mysql57-community-release-el7.rpm
    
  7. 安装MySql
    yum install -y mysql-server
    
  8. 安装成功后,启动mysql
    systemctl start mysqld
    
  9. 查看初始的root密码,这个root是mysql的root
    grep 'temporary password' /var/log/mysqld.log
    
    找到root@localhost:后的一串字符加符号的组合,它就是初始密码。
  10. 更改密码
    mysql_secure_installation
    
    出现New password表示要求输入新密码,一路Y过去,出现All done! 表示成功!
  11. 设置开机启动
    systemctl enable mysqld
    
  12. 防火墙3306(可以试试,反正我的没生效,直接把防火墙关掉了!)
    firewall-cmd --zone=public --add-service=mysql --permanent
    
    //这种方法没试过,可以试试。
    firewall-cmd --zone=public --add-port=3306\tcp --permanent
    //出现success之后,再使用firewall-cmd --reload使策略生效
  13. 开启远程登陆
    mysql -u root -p
    use mysql;
    update user set user.Host='%' where user.User='root';
    select host,user from user; //查看是否成功
    
posted @ 2021-10-29 17:02  ☆のLueng☆  阅读(295)  评论(0编辑  收藏  举报