Centos 7 安装mysql数据库

前端之家收集整理的这篇文章主要介绍了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 @L_404_0@

    [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. 修改防火墙配置

猜你在找的CentOS相关文章