ITPub博客

首页 > 数据库 > MySQL > ERROR 2002 (HY000): Can't connect server socket /tmp/mysql.sock

ERROR 2002 (HY000): Can't connect server socket /tmp/mysql.sock

原创 MySQL 作者:starive 时间:2014-09-28 10:21:03 0 删除 编辑
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


自己采用的解决方案:
启动MySQL数据库:


***@***-VirtualBox:~$ sudo /etc/init.d/mysql.server start
Starting MySQL
.... * The server quit without updating PID file (/usr/local/mysql/data/***-VirtualBox.pid).

针对以上错误,网上各种百度,各种谷歌都解决不了,还是提示上面的同样的错误


我采用下面的方法,竟然可以启动MySQL,但是又引发了其他的无法解决的error
##################################    方法如下    ##############################
按照网址:http://www.justin.my/2012/03/starting-mysql-error-the-server-quit-without-updating-pid-file/
竟然可以启动MySQL服务,如下:
***@***-VirtualBox:/etc$ sudo mv /etc/my.cnf /etc/my.cnf.old
***@***-VirtualBox:/etc$ sudo /etc/init.d/mysql.server start
Starting MySQL
.. * 

但是,无法登陆了:
***@***-VirtualBox:/etc/mysql/conf.d$ sudo mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


这个错误我用了各种办法无法解决,无奈把my.cnf的名称变回来:

***@***-VirtualBox:/etc$ sudo mv /etc/my.cnf.old  /etc/my.cnf
####################################################################



解决方法:

查看错误日志,定位到日志最后几行:***@***-VirtualBox:/usr/local/mysql$ more ./data/***-VirtualBox.err

 

##### 日志内容  start #####

140928 08:52:32 mysqld_safe mysqld from pid file /usr/local/mysql/data/ga

oyu-VirtualBox.pid ended

140928 10:53:01 mysqld_safe Starting mysqld daemon with databases from /u

sr/local/mysql/data

140928 10:53:01 [Note] Plugin 'FEDERATED' is disabled.

140928 10:53:01 InnoDB: The InnoDB memory heap is disabled

140928 10:53:01 InnoDB: Mutexes and rw_locks use InnoDB's own implementat

ion

140928 10:53:01 InnoDB: Compressed tables use zlib 1.2.3

140928 10:53:01 InnoDB: Using Linux native AIO

140928 10:53:01 InnoDB: Initializing buffer pool, size = 128.0M

140928 10:53:01 InnoDB: Completed initialization of buffer pool

140928 10:53:01 InnoDB: highest supported file format is Barracuda.

140928 10:53:01  InnoDB: Waiting for the background threads to start

140928 10:53:02 InnoDB: 5.5.39 started; log sequence number 44664632

140928 10:53:02 [ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'de

fault-character-set=utf8'

140928 10:53:02 [ERROR] Aborting







140928 10:53:02  InnoDB: Starting shutdown...

140928 10:53:03  InnoDB: Shutdown completed; log sequence number 44664632

140928 10:53:03 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete


140928 10:53:03 mysqld_safe mysqld from pid file /usr/local/mysql/data/ga

oyu-VirtualBox.pid ended

 

##### 日志内容  end #####   

 

 

记得自己为了解决同事的字符编码问题,把自己机器上面的配置文件修改过:修改了/etc/my.cnf里面的【mysqld】的字符设置,在修改回来,试试看,修改方法如下:

把 [client] [mysqld] [mysql]里面的  default-character-set=utf8 都注释掉


发现好使了,可以成功登陆MySQL了。

***@***-VirtualBox:/usr/local/mysql$ sudo /etc/init.d/mysql.server start

Starting MySQL

.... * 

***@***-VirtualBox:/usr/local/mysql$ sudo mysql -u root -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.39-log MySQL Community Server (GPL)

 

Copyright (c) 2000, 2014, 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> 

 



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26435490/viewspace-1283327/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 权限管理
下一篇: 可用性
请登录后发表评论 登录
全部评论

注册时间:2014-01-18

  • 博文量
    143
  • 访问量
    530075