MySQL的安装------三种方式--RPM

MySQL Install 5.7.24

www.mysql.com
www.oracle.com
http://dev.mysql.com/doc/refman/5.7/en/linux-installation.html

Oracle MySQL、MariaDB、Percona server

MySQL的安装------三种方式--RPM_第1张图片

安装环境

[root@mysql1 ~]# rpm -q mariadb-server
package mariadb-server is not installed

[root@mysql1 ~]# sed -ri ‘/^SELINUX=/c\SELINUX=disabled’ /etc/selinux/config
[root@mysql1 ~]# setenforce 0

方法一:二进制 rpm

    http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

rpm -ivh  mysql57-community-release-el7-9.noarch.rpm
yum -y install mysql-server
mysql -uroot -p'123'
 show databases;

 [root@tianyun Downloads]# md5sum mysql57-community-release-el7-9.noarch.rpm
 [root@tianyun Downloads]# yum -y install mysql57-community-release-el7-9.noarch.rpm
[root@git ~]# yum repolist
 Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                       repo name                               status
base/7/x86_64                      CentOS-7 - Base                         10,019
extras/7/x86_64                      CentOS-7 - Extras                          321
mysql-connectors-community/x86_64       MySQL Connectors Community                  74
mysql-tools-community/x86_64     MySQL Tools Community                 74
mysql57-community/x86_64        MySQL 5.7 Community Server          307
updates/7/x86_64                   CentOS-7 - Updates                         628
repolist: 11,423

 [root@git ~]# yum repolist all | grep mysql
        mysql-connectors-community/x86_64 MySQL Connectors Community     enabled:     74
        mysql-connectors-community-source MySQL Connectors Community - S disabled
        mysql-tools-community/x86_64      MySQL Tools Community               enabled:             74
        mysql-tools-community-source      MySQL Tools Community - Source disabled
        mysql-tools-preview/x86_64        MySQL Tools Preview                    disabled
        mysql-tools-preview-source           MySQL Tools Preview - Source   disabled
        mysql55-community/x86_64          MySQL 5.5 Community Server     disabled
        mysql55-community-source          MySQL 5.5 Community Server - S disabled
        mysql56-community/x86_64          MySQL 5.6 Community Server     disabled
        mysql56-community-source          MySQL 5.6 Community Server - S disabled
        mysql57-community/x86_64          MySQL 5.7 Community Server     enabled:          307
        mysql57-community-source          MySQL 5.7 Community Server - S disabled
        mysql80-community/x86_64          MySQL 8.0 Community Server     disabled
        mysql80-community-source          MySQL 8.0 Community Server - S disabled

 [root@git ~]# yum-config-manager --enable mysql56-community
       将此56的MySQL设置成开机自启动
       报错解决方式:
                   -bash: yum-config-manager: command not found
                   这个是因为系统默认没有安装这个命令,这个命令在yum-utils 包里。
                    yum -y install yum-utils
       
 [root@git ~]# yum repolist enabled | grep mysql
                mysql-connectors-community/x86_64       MySQL Connectors Community            74
                mysql-tools-community/x86_64            MySQL Tools Community                 74
                mysql56-community/x86_64                MySQL 5.6 Community Server           429
                mysql57-community/x86_64                MySQL 5.7 Community Server           307

  

 [root@mysql1 ~]# yum -y install mysql-community-server
 [root@mysql1 ~]# systemctl start mysqld                                 //第一次启动先初始数据库
 [root@mysql1 ~]# systemctl enable mysqld
[root@mysql1 ~]# ls /var/lib/mysql
            auto.cnf            client-key.pem      ib_logfile1         mysql.sock.lock                  server-cert.pem
            ca-key.pem       ib_buffer_pool       ibtmp1             performance_schema          server-key.pem
            ca.pem             ibdata1                  mysql               private_key.pem                 sys
            client-cert.pem  ib_logfile0            mysql.sock          public_key.pem

 
 [root@mysql ~]# grep "password" /var/log/mysqld.log 
                2019-01-15T06:45:28.734665Z 1 [Note] A temporary password is generated for root@localhost: VFISQo_dt7Rt
                2019-01-15T06:47:41.765992Z 3 [Note] Access denied for user 'root'@'localhost' (using password: YES)
[root@mysql ~]# mysql -uroot -p'VFISQo_dt7Rt'
                mysql: [Warning] Using a password on the command line interface can be insecure.
                Welcome to the MySQL monitor.  Commands end with ; or \g.
                Your MySQL connection id is 5
                Server version: 5.7.24 MySQL Community Server (GPL)

                Copyright (c) 2000, 2018, 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> 
                
                
                
                
     mysql>   alter  user  'root'@'localhost' identified by "1qaz2WSX#";      修改密码
     Query OK, 1 row affected (0.00 sec)
    mysql> \q
     Bye
                 
                 
                 
    mysql> show databases;
                            +--------------------+
                            | Database           |
                            +--------------------+
                            | information_schema |
                            | mysql              |
                            | performance_schema |
                            | sys                |
                            +--------------------+
                            4 rows in set (0.01 sec)

                            mysql> 
           


你可能感兴趣的:(相应服务问题)