在CentOS 8上安装MySQL 8

70次阅读
没有评论

一、概述

基于CentOS8.3mini 安装Mysql 8

二、开始安装

  1. 查看mysql模块

    # dnf whatprovides mysql
    mysql-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64 : MySQL client programs and shared libraries
    Repo : AppStream
    Matched from:
    Provide : mysql = 8.0.13-1.module_el8.0.0+41+ca30bab6

    因此,只需运行以下命令即可轻松安装MySQL 8服务器;

    dnf install mysql-server

    同时安装MySQL 8服务器和客户端;

    dnf install @mysql
    =======================================================================================================================================================
    Package Arch Version Repository Size
    =======================================================================================================================================================
    Installing group/module packages:
    mysql-server x86_64 8.0.13-1.module_el8.0.0+41+ca30bab6 AppStream 25 M
    Installing dependencies:
    mariadb-connector-c-config noarch 3.0.7-1.el8 AppStream 13 k
    mecab x86_64 0.996-1.module_el8.0.0+41+ca30bab6.9 AppStream 397 k
    mysql x86_64 8.0.13-1.module_el8.0.0+41+ca30bab6 AppStream 9.2 M
    mysql-common x86_64 8.0.13-1.module_el8.0.0+41+ca30bab6 AppStream 142 k
    mysql-errmsg x86_64 8.0.13-1.module_el8.0.0+41+ca30bab6 AppStream 523 k
    protobuf-lite x86_64 3.5.0-7.el8 AppStream 150 k
    Installing module profiles:
    mysql/server 
    Enabling module streams:
    mysql 8.0 
    Transaction Summary
    =======================================================================================================================================================
    Install 7 Packages
    Total download size: 36 M
    Installed size: 243 M
    Is this ok [y/N]: y
  2. 在CentOS 8上运行MySQL 8
    安装完成后,启动并启用MySQL 8服务器以在系统启动时运行。

    # systemctl start mysqld
    # systemctl enable mysqld
  3. 检查MySQL 8服务器的状态;

    systemctl status mysqld
    ● mysqld.service - MySQL 8.0 database server
    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
    Active: active (running) since Wed 2019-10-02 13:19:32 EDT; 42s ago
    Main PID: 29142 (mysqld)
    Status: "SERVER_OPERATING"
    Tasks: 38 (limit: 11512)
    Memory: 466.4M
    CGroup: /system.slice/mysqld.service
    └─29142 /usr/libexec/mysqld --basedir=/usr
    Oct 02 13:19:20 localhost.localdomain systemd[1]: Starting MySQL 8.0 database server...
    Oct 02 13:19:20 localhost.localdomain mysql-prepare-db-dir[29057]: Initializing MySQL database
    Oct 02 13:19:32 localhost.localdomain systemd[1]: Started MySQL 8.0 database server.
  4. MySQL 8初始安全性
    默认情况下,MySQL附带安全脚本,该脚本用于删除测试MySQL服务器数据库,删除数据库中的匿名用户,禁用远程root登录,设置密码强度,要运行脚本,只需执行命令;

    #mysql_secure_installation

    运行时,系统会提示你是启用还是禁用密码策略,如果启用,请设置密码策略并创建与所选策略匹配的密码。

    VALIDATE PASSWORD COMPONENT can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. Would you like to setup VALIDATE PASSWORD component?
    Press y|Y for Yes, any other key for No: y
    There are three levels of password validation policy:
    LOW Length >= 8
    MEDIUM Length >= 8, numeric, mixed case, and special characters
    STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
    Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
    Please set the password for root here.
    New password: 
    Re-enter new password: 
    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
  5. 接下来,删除匿名用户,禁止远程root登录,删除测试数据库并重新加载权限表以完成所做的更改。
    你现在可以使用上面设置的密码以root用户身份登录到MySQL 8服务器。

    mysql -u root -p

    要显示mysql版本,可以运行查询;

    show variables like "version%";
    +-------------------------+---------------------+
    | Variable_name | Value |
    +-------------------------+---------------------+
    | version | 8.0.13 |
    | version_comment | Source distribution |
    | version_compile_machine | x86_64 |
    | version_compile_os | Linux |
    | version_compile_zlib | 1.2.11 |
    +-------------------------+---------------------+
正文完
 
oakcdrom
版权声明:本站原创文章,由 oakcdrom 2021-05-25发表,共计3360字。
转载说明:转载请注明出处。
评论(没有评论)