微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Centos 7 安装mysql数据库

  1. 查看Linux版本

    [root@localhost ~]# cat /etc/redhat-release
    CentOS Linux release 7.1.1503 (Core)

  2. 因为Centos7 里面没有MysqL的yum源,重新下载建立yum源,然后创建MysqL数据库

    [root@localhost ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

    [root@localhost ~]# rpm -ivh MysqL-community-release-el7-5.noarch.rpm

    [root@localhost ~]# yum install MysqL-server

  3. 登录数据库

    [root@localhost opt]# MysqL -u root
    ERROR 2002 (HY000): Can’t connect to local MysqL server through socket ‘/var/lib/MysqL/MysqL.sock’ (2)

    注意:/var/lib/MysqL的访问权限问题,将该文件夹的所有者改为root用户

    [root@localhost opt]# chown -R root:root /var/lib/MysqL

  4. 重启MysqLd 服务

    [root@localhost opt]# service MysqLd restart

  5. 重新登录MysqL

    [root@localhost opt]# MysqL -u root
    Welcome to the MysqL monitor. Commands end with ; or \g.
    Your MysqL connection id is 2
    Server version: 5.6.34 MysqL Community Server (GPL)

    copyright (c) 2000,2016,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> use MysqL

    MysqL> update user set password=password(“123456”) where user=’root’;
    Query OK,4 rows affected (0.15 sec)
    Rows matched: 4 Changed: 4 Warnings: 0

    MysqL> exit
    Bye
    [root@localhost opt]#

  6. 修改防火墙配置

原文地址:https://www.jb51.cc/centos/380018.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。