linux|[linux-29] 安装mysql5.7(CentOS7.6)

  1. [root@test100 bin]# mkdir /opt/mysql
  2. [root@test100 bin]# cd /opt/mysql
  3. [root@test100 mysql]# ll
    总用量 518444
    -rw-r–r--. 1 root root 530882560 3月 27 23:41 mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
  4. [root@test100 mysql]# tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
  5. [root@test100 mysql]# ls
    mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar mysql-community-embedded-devel-5.7.26-1.el7.x86_64.rpm
    mysql-community-client-5.7.26-1.el7.x86_64.rpm mysql-community-libs-5.7.26-1.el7.x86_64.rpm
    mysql-community-common-5.7.26-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm
    mysql-community-devel-5.7.26-1.el7.x86_64.rpm mysql-community-server-5.7.26-1.el7.x86_64.rpm
    mysql-community-embedded-5.7.26-1.el7.x86_64.rpm mysql-community-test-5.7.26-1.el7.x86_64.rpm
    mysql-community-embedded-compat-5.7.26-1.el7.x86_64.rpm
    tips:CnetOD7.6自带的类mysql数据库是mariadb,会跟mysql冲突,要先删除
    [root@test100 mysql]# rpm -qa | grep mari
    linux|[linux-29] 安装mysql5.7(CentOS7.6)
    文章图片

  6. [root@test100 mysql]# rpm -e --nodeps mariadb-libs
    [root@test100 mysql]# rpm -e --nodeps marisa-0.2.4-4.el7.x86_64
    [root@test100 mysql]# rpm -qa | grep mari
    linux|[linux-29] 安装mysql5.7(CentOS7.6)
    文章图片

  7. 按顺序执行安装
    [root@test100 mysql]# rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
    [root@test100 mysql]# rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
    [root@test100 mysql]# rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
    [root@test100 mysql]# rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
  8. 启动服务
    [root@test100 mysql]# systemctl start mysqld.service
  9. 【linux|[linux-29] 安装mysql5.7(CentOS7.6)】设置root用户密码
    mysql自动给root用户设置随机密码,运行grep “password” /var/log/mysqld.log,可看到当前密码
  10. 运行mysql -u root -p,用随机密码登录
    生产环境的密码,要尽可能复杂
    set global validate_password_policy=0;
    (validate_password_policy默认值是1)
    set password for ‘root’@‘localhost’=password(‘hspedu100’);
    11.flush privileges;
    是密码设置生效 linux|[linux-29] 安装mysql5.7(CentOS7.6)
    文章图片

    linux|[linux-29] 安装mysql5.7(CentOS7.6)
    文章图片

    推荐阅读