CentOS7使用rpm安装MySQL8

  1. 到官网下载最新的的安装包:

    [root@study data]# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
    
  2. 卸载CentOS7自带的MariaDB依赖:

    [root@study selinux]# rpm -qa|grep mariadb
    mariadb-libs-5.5.60-1.el7_5.x86_64
    [root@study selinux]# rpm -e --nodeps mariadb-libs
    [root@study selinux]# rpm -qa|grep mariadb
    
  3. 解压下载的安装包

    [root@study data]# tar -xvf mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
    
  4. 安装net-tools

    [root@study data]# yum -y install net-tools
    
  5. 依次安装mysql包

    [root@study data]# rpm -ivh mysql-community-common-8.0.13-1.el7.x86_64.rpm
    [root@study data]# rpm -ivh mysql-community-libs*
    [root@study data]# rpm -ivh mysql-community-client-8.0.13-1.el7.x86_64.rpm
    [root@study data]# rpm -ivh  mysql-community-server-8.0.13-1.el7.x86_64.rpm
    warning: mysql-community-server-8.0.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    error: Failed dependencies:
      /usr/bin/perl is needed by mysql-community-server-8.0.13-1.el7.x86_64
      perl(Getopt::Long) is needed by mysql-community-server-8.0.13-1.el7.x86_64
      perl(strict) is needed by mysql-community-server-8.0.13-1.el7.x86_64
    ### 安装缺失的perl依赖包
    [root@study data]# yum install perl
    [root@study data]# rpm -ivh  mysql-community-server-8.0.13-1.el7.x86_64.rpm
    
  6. 启动mysql,获取默认root密码,登录mysql数据库

    [root@study data]# systemctl start mysqld.service
    [root@study data]# grep 'temporary password' /var/log/mysqld.log
    2018-11-16T15:15:20.149816Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: J/V3,F-pa;>X
    [root@study data]# mysql -uroot -p
    
  7. 初始化mysql

    [root@study data]# mysql_secure_installation
    
    Securing the MySQL server deployment.
    
    Enter password for user root: 
    The 'validate_password' component is installed on the server.
    The subsequent steps will run with the existing configuration
    of the component.
    Using existing password for root.
    
    Estimated strength of the password: 100 
    Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
    
    New password: $RFV5tgb
    
    Re-enter new password: $RFV5tgb
    
    Estimated strength of the password: 100 
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
    By default, a MySQL installation has an anonymous user,
    allowing anyone to log into MySQL without having to have
    a user account created for them. This is intended only for
    testing, and to make the installation go a bit smoother.
    You should remove them before moving into a production
    environment.
    
    Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    
    Normally, root should only be allowed to connect from
    'localhost'. This ensures that someone cannot guess at
    the root password from the network.
    
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    By default, MySQL comes with a database named 'test' that
    anyone can access. This is also intended only for testing,
    and should be removed before moving into a production
    environment.
    
    
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
    - Dropping test database...
    Success.
    
    - Removing privileges on test database...
    Success.
    
    Reloading the privilege tables will ensure that all changes
    made so far will take effect immediately.
    
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    All done!
    
  8. 修改root密码,新建study用户

    ### 初始化时已更改root密码,这里可以省略
    # mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '$RFV5tgb';
    ### 这里是避免SQLyog连接8.0报:Error No.2058 Plugin caching_sha2_password could not be loaded,后续工具更新后,再使用8.0新的加密方式
    mysql> CREATE USER 'study'@'localhost' IDENTIFIED WITH mysql_native_password BY '^YHN7ujm';
    ### 授予study所有权限
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'study'@'localhost' WITH GRANT OPTION;
    
  9. 用SQLyog进行连接

    ps: 由于mysql没有开启远程连接,通过ssh连接跳转

    1. 配置SSH Tunneling
    配置ssh
    1. 填写mysql连接信息,注意host填:127.0.0.1
    配置mysql连接

你可能感兴趣的:(CentOS7使用rpm安装MySQL8)