美文网首页
在centos7中使用yum安装mysql数据库并使用navic

在centos7中使用yum安装mysql数据库并使用navic

作者: 半理想主义 | 来源:发表于2022-04-28 11:17 被阅读0次

    2、初始化

    1.尝试进入mysql, 报错了,是没有权限

    [root@server-mysql src]# mysql -u root
        ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
    

    2.查看mysql所属的用户,发现是mysql

    [root@server-mysql src]# ll /var/lib/ | grep mysql
        drwxr-xr-x. 2 mysql   mysql      6 6月  15 21:36 mysql
        drwxr-x---. 2 mysql   mysql      6 6月  15 21:36 mysql-files
    

    3.将其更改为当前用户(root)

    [root@server-mysql src]# chown -R root:root /var/lib/mysql*
    [root@server-mysql src]# ll /var/lib/ | grep mysql
        drwxr-xr-x. 2 root    root       6 6月  15 21:36 mysql
        drwxr-x---. 2 root    root       6 6月  15 21:36 mysql-files
    

    4.重启mysql

    [root@server-mysql src]# systemctl restart mysqld
    

    5.再次进入数据库,并查看已有数据库

    [root@server-mysql src]# mysql -u root
        Welcome to the MySQL monitor.  Commands end with ; or \g.
        Your MySQL connection id is 3
        Server version: 5.6.41 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> show databases;
        +--------------------+
        | Database           |
        +--------------------+
        | information_schema |
        | mysql              |
        | performance_schema |
        +--------------------+
        3 rows in set (0.00 sec)
    

    相关文章

      网友评论

          本文标题:在centos7中使用yum安装mysql数据库并使用navic

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