美文网首页
Centos x64 6.8 yum install mysql

Centos x64 6.8 yum install mysql

作者: 师娘哪里去了 | 来源:发表于2019-10-16 15:45 被阅读0次

    下载并安装用来配置mysql的yum源的rpm包

    # 下载
    wget http://repo.mysql.com/mysql57-community-release-el6-10.noarch.rpm
    # 安装
    yum -y localinstall mysql57-community-release-el6-10.noarch.rpm
    # 或
    rpm -Uvh mysql57-community-release-el6-10.noarch.rpm
    

    安装成功后在/etc/yum.repos.d/下会多出几个mysql的yum源的配置,如下:

    [root@keepmydream ~]# ls -lh  /etc/yum.repos.d/
    total 36K
    -rw-r--r--. 1 root root 2.5K Jun 16 06:21 CentOS-Base.repo
    -rw-r--r--. 1 root root 2.0K Mar 28  2017 CentOS-Base.repo.back
    -rw-r--r--. 1 root root  647 Mar 28  2017 CentOS-Debuginfo.repo
    -rw-r--r--. 1 root root  289 Mar 28  2017 CentOS-fasttrack.repo
    -rw-r--r--. 1 root root  630 Mar 28  2017 CentOS-Media.repo
    -rw-r--r--. 1 root root 7.9K Mar 28  2017 CentOS-Vault.repo
    -rw-r--r--. 1 root root 1.6K Apr  5  2017 mysql-community.repo
    -rw-r--r--. 1 root root 1.7K Apr  5  2017 mysql-community-source.repo
    

    安装mysql

    [root@keepmydream ~]# yum -y install mysql-community-server
    

    安装成功后查看版本

    [root@keepmydream ~]# mysql -V
    mysql Ver 14.14 Distrib 5.7.23, for Linux (x86_64) using EditLine wrapper
    

    启动MySQL

    [root@localhost ~]# service mysqld start
    Initializing MySQL database:                               [  OK  ]
    Starting mysqld:                                           [  OK  ]
    

    查看原始密码

    [root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
    2019-10-16T08:03:51.953930Z 1 [Note] A temporary password is generated for root@localhost: M8c,-k%PptxW
    

    链接数据库测试:

    [root@localhost ~]# mysql -uroot -pM8c,-k%PptxW
    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 3
    Server version: 5.7.28
    
    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>
    

    使用前准备

    修改默认密码(mysql强制修改初始密码)

    mysql>  ALTER USER USER() IDENTIFIED BY 'Abcd123456.';
    Query OK, 0 rows affected (0.00 sec)
    

    修改链接策略,允许其它非本地IP访问

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

    enjoy it~~~

    相关文章

      网友评论

          本文标题:Centos x64 6.8 yum install mysql

          本文链接:https://www.haomeiwen.com/subject/wlrumctx.html