• Centos 安装 MySql


    参考资料

    https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

    下载 rpm

    https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
    

    将 rpm 上传到服务器

    [root@localhost bin]# cd /home/download
    [root@localhost download]# ll
    总用量 210228
    -rw-r--r--. 1 root root 194990602 5月   6 15:32 jdk-8u211-linux-x64.tar.gz
    -rw-r--r--. 1 root root     26024 5月   6 16:07 mysql80-community-release-el7-3.noarch.rpm
    -rw-r--r--. 1 root root   1014040 11月  6 23:26 nginx-1.14.1.tar.gz
    -rw-r--r--. 1 root root  19231911 5月  17 2018 zookeeper-3.5.4-beta.tar.gz
    

    执行 rpm 命令

    [root@localhost download]# rpm -Uvh mysql80-community-release-el7-3.noarch.rpm 
    警告:mysql80-community-release-el7-3.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
    准备中...                          ################################# [100%]
    正在升级/安装...
       1:mysql80-community-release-el7-3  ################################# [100%]
    
    

    查看包

    [root@localhost download]# yum repolist all | grep mysql
    mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community      禁用
    mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - So 禁用
    mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community      禁用
    mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - So 禁用
    mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community      禁用
    mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - So 禁用
    mysql-connectors-community/x86_64  MySQL Connectors Community       启用:    108
    mysql-connectors-community-source  MySQL Connectors Community - Sou 禁用
    mysql-tools-community/x86_64       MySQL Tools Community            启用:     89
    mysql-tools-community-source       MySQL Tools Community - Source   禁用
    mysql-tools-preview/x86_64         MySQL Tools Preview              禁用
    mysql-tools-preview-source         MySQL Tools Preview - Source     禁用
    mysql55-community/x86_64           MySQL 5.5 Community Server       禁用
    mysql55-community-source           MySQL 5.5 Community Server - Sou 禁用
    mysql56-community/x86_64           MySQL 5.6 Community Server       禁用
    mysql56-community-source           MySQL 5.6 Community Server - Sou 禁用
    mysql57-community/x86_64           MySQL 5.7 Community Server       禁用
    mysql57-community-source           MySQL 5.7 Community Server - Sou 禁用
    mysql80-community/x86_64           MySQL 8.0 Community Server       启用:     99
    mysql80-community-source           MySQL 8.0 Community Server - Sou 禁用
    

    启用 57 。禁用 80

    [root@localhost download]# sudo yum-config-manager --disable mysql80-community
    
    [root@localhost download]# sudo yum-config-manager --enable mysql57-community
    
    [root@localhost download]# yum repolist enabled | grep mysql
    mysql-connectors-community/x86_64       MySQL Connectors Community           108
    mysql-tools-community/x86_64            MySQL Tools Community                 89
    mysql57-community/x86_64                MySQL 5.7 Community Server           347
    

    安装

    yum install mysql-community-server
    
    依赖关系解决
    
    =================================================================================================================================================================================================================================================
     Package                                                              架构                                            版本                                                      源                                                          大小
    =================================================================================================================================================================================================================================================
    正在安装:
     mysql-community-libs                                                 x86_64                                          5.7.26-1.el7                                              mysql57-community                                          2.2 M
          替换  mariadb-libs.x86_64 1:5.5.56-2.el7
     mysql-community-libs-compat                                          x86_64                                          5.7.26-1.el7                                              mysql57-community                                          2.0 M
          替换  mariadb-libs.x86_64 1:5.5.56-2.el7
     mysql-community-server                                               x86_64                                          5.7.26-1.el7                                              mysql57-community                                          166 M
    为依赖而安装:
     mysql-community-client                                               x86_64                                          5.7.26-1.el7                                              mysql57-community                                           24 M
     mysql-community-common                                               x86_64                                          5.7.26-1.el7                                              mysql57-community                                          274 k
    为依赖而更新:
     postfix                                                              x86_64                                          2:2.10.1-7.el7                                            base                                                       2.4 M
    
    事务概要
    =================================================================================================================================================================================================================================================
    安装  3 软件包 (+2 依赖软件包)
    升级           ( 1 依赖软件包)
    
    总下载量:197 M
    Is this ok [y/d/N]: y
    Downloading packages:
    Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
    警告:/var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.26-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY                                                      ] 171 kB/s | 1.0 MB  00:19:29 ETA 
    mysql-community-common-5.7.26-1.el7.x86_64.rpm 的公钥尚未安装
    (1/6): mysql-community-common-5.7.26-1.el7.x86_64.rpm                                                                                                                                                                     | 274 kB  00:00:06     
    (2/6): mysql-community-libs-5.7.26-1.el7.x86_64.rpm                                                                                                                                                                       | 2.2 MB  00:00:05     
    (3/6): mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm                                                                                                                                                                | 2.0 MB  00:00:13     
    (4/6): postfix-2.10.1-7.el7.x86_64.rpm      
    

    启动 mysql

    [root@localhost home]# service mysqld start
    Redirecting to /bin/systemctl start mysqld.service
    
    [root@localhost home]# service mysqld status
    Redirecting to /bin/systemctl status mysqld.service
    ● mysqld.service - MySQL Server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
       Active: active (running) since 一 2019-05-06 16:41:58 CST; 23s ago
         Docs: man:mysqld(8)
               http://dev.mysql.com/doc/refman/en/using-systemd.html
      Process: 2818 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
      Process: 2744 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
     Main PID: 2821 (mysqld)
       CGroup: /system.slice/mysqld.service
               └─2821 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
    
    5月 06 16:41:48 localhost.localdomain systemd[1]: Starting MySQL Server...
    5月 06 16:41:58 localhost.localdomain systemd[1]: Started MySQL Server.
    
    

    修改密码

    [root@localhost home]# grep 'temporary password' /var/log/mysqld.log
    2019-05-06T08:41:48.727949Z 1 [Note] A temporary password is generated for root@localhost: r#qtUrwlo22E
    [root@localhost home]# mysql -uroot -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.26
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123123';
    ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    

    设置密码策略,重新修改密码

    mysql> SHOW VARIABLES LIKE 'validate_password%'
        -> ;
    +--------------------------------------+--------+
    | Variable_name                        | Value  |
    +--------------------------------------+--------+
    | validate_password_check_user_name    | OFF    |
    | validate_password_dictionary_file    |        |
    | validate_password_length             | 8      |
    | validate_password_mixed_case_count   | 1      |
    | validate_password_number_count       | 1      |
    | validate_password_policy             | MEDIUM |
    | validate_password_special_char_count | 1      |
    +--------------------------------------+--------+
    7 rows in set (0.01 sec)
    
    mysql> set global validate_password_length=6
        -> ;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> SHOW VARIABLES LIKE 'validate_password%'
        -> ;
    +--------------------------------------+--------+
    | Variable_name                        | Value  |
    +--------------------------------------+--------+
    | validate_password_check_user_name    | OFF    |
    | validate_password_dictionary_file    |        |
    | validate_password_length             | 6      |
    | validate_password_mixed_case_count   | 1      |
    | validate_password_number_count       | 1      |
    | validate_password_policy             | MEDIUM |
    | validate_password_special_char_count | 1      |
    +--------------------------------------+--------+
    7 rows in set (0.00 sec)
    
    mysql>  ALTER USER 'root'@'localhost' IDENTIFIED BY '123123';
    ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    mysql> set global validate_password_policy=LOW;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123123';
    Query OK, 0 rows affected (0.00 sec)
    
    

    开放 3306 端口

    [root@localhost home]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
    success
    [root@localhost home]# firewall-cmd --reload
    success
    

    使用客户端连接

    解决客户端连接错误

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123123' WITH GRANT OPTION; 
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    

    客户端正常连接,安装成功

  • 相关阅读:
    asp.net core 集成JWT(一)
    Microsoft.Extensions.DependencyInjection中的Transient依赖注入关系,使用不当会造成内存泄漏
    Microsoft.Extensions.DependencyInjection的Singleton依赖注入关系,只是对于同一个ServiceProvider是单例的
    ASP.NET Core MVC中,如何将视图文件生成的html代码通过字符串返回
    SpringBoot魔法堂:说说带智能提示的spring-boot-starter
    Maven魔法堂:安装Oracle JDBC Driver依赖的那些坑
    TypeScript魔法堂:函数类型声明其实很复杂
    TypeScript魔法堂:枚举的超实用手册
    C#获取文件与文件夹默认图标(2006-3-22 新增示例代码与程序)
    【学习笔记】Team Explorer for Microsoft Visual Studio2015 安装时发生严重错误
  • 原文地址:https://www.cnblogs.com/panzi/p/10820346.html
Copyright © 2020-2023  润新知