• ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'


    故障描述:

    启动mysql 报错:
    ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)


    1.先查看mysql启动状态

    #/etc/rc.d/init.d/mysqld status

    2.mysql.sock位置查找与验证?

    # find / -name mysql.sock
    /Data/mydata/mysql.sock
    验证目录是否正确
    #mysql -u root -p -S /Data/mydata/mysql.sock

    备注:-S参数socket file文件验证

    3.验证mysql.sock文件权限和用户是否正确?如果是权限问题,则先改变权限 
    #chown -R mysql:mysql /Data/mydata/mysql.sock


    [root@localhost ~]# /etc/init.d/mysqld start
    启动 MySQL: [ OK]

    4.永久解决

    修改/etc/my.cnf

    添加以下内容到/etc/my.conf:
    [client]
    socket = /Data/mydata/mysql.sock
    [mysqld]

    socket = /Data/mydata/mysql.sock

    5、终极大招~~~~~~

    实际检查发现,yum安装的没有mysql.sock,没有my.conf

    ...那一定是漏了什么,果然,mysql-server没装

    yum install mysql-server

    /etc/init.d/mysqld start

    [ OK ]
    Starting mysqld: [ OK ]

  • 相关阅读:
    Android 锁屏 临时屏蔽
    单编译framework相关模块
    02
    pad 强制加载 Hdpi资源 (2.3 dpi < 240)
    设置form的默认按钮
    How to Be a Good Graduate Student
    我怕你们急于求成
    希腊字母读音表
    数据库札记(二)
    Ubuntu 9.04下jdk的安装与配置
  • 原文地址:https://www.cnblogs.com/yihr/p/9671524.html
Copyright © 2020-2023  润新知