zoukankan      html  css  js  c++  java
  • CentOS 7 安装 MySQL 8.0x,踩坑记录

    具体安装步骤,推荐参考这篇文章的第一部分【YUM方式】来安装:

    https://segmentfault.com/a/1190000037702065

    如果出现 Can't connect to local MySQL server through socket '/tmp/mysql.sock'

    可以参考这篇文章 https://developer.aliyun.com/article/435802,在 /etc/my.cnf 中添加配置文件:

    重启 MySQL 的方法:

    # 查看状态:
    systemctl status mysqld
    # 重启:
    systemctl restart mysqld
    

    root 用户连接 MySQL 时:

    [root@onepiece ~]# mysql -uroot -p
    Enter password:
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (13)

    而 mysql 用户连接是没有问题的:

    [root@onepiece ~]# su - mysql
    Last login: Sat Nov 27 13:32:03 CST 2021 on pts/2
    -sh-4.2$
    -sh-4.2$ mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 18
    Server version: 8.0.27 MySQL Community Server - GPL

    Copyright (c) 2000, 2021, Oracle and/or its affiliates.

    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> exit

    参考博客:https://blog.csdn.net/hjf161105/article/details/78850658

    原因大概是:在安装 MySQL 服务的时候,/tmp/mysql.sock 是关联了 mysql 用户创建的套接字,root 用户要连接 MySQL,应该重新创建套接字,比如这样:

    [root@onepiece ~]# mysql -h127.0.0.1 -P3306 -uroot -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 19
    Server version: 8.0.27 MySQL Community Server - GPL

    Copyright (c) 2000, 2021, Oracle and/or its affiliates.

    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> exit
    Bye
    [root@onepiece ~]#

  • 相关阅读:
    MySQL慢日志
    百万级数据生成。
    layui的数据表格加上操作
    WINDOWS命令行关闭本地占用的端口
    项目中路径问题
    linux服务器上使用find查杀webshell木马方法
    mysql锁分析相关的几个系统视图
    Centos7中网络及设备相关配置
    centos7版本中ssh相关的设置
    mysql权限参考
  • 原文地址:https://www.cnblogs.com/shoufeng/p/15612451.html
Copyright © 2011-2022 走看看