mysql - 错误 2002 (HY000) : Can't connect to local M

我收到了这个错误

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

尽管我已经设法在 ubuntu 中通过命令行启动了 mysql

mysql stop/waiting
mysql start/running, process 17691

但是,当我尝试访问该站点时,我得到一个数据库连接错误以及尝试通过 mysql -u root -p

访问 mysql 时出现上述错误

我检查了我的错误日志并看到了这个

    131029 12:53:34 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be remo$
    131029 12:53:34 [Note] Plugin 'FEDERATED' is disabled.
    131029 12:53:34 InnoDB: The InnoDB memory heap is disabled
    131029 12:53:34 InnoDB: Mutexes and rw_locks use GCC atomic builtins
    131029 12:53:34 InnoDB: Compressed tables use zlib 1.2.3.4
    131029 12:53:34 InnoDB: Initializing buffer pool, size = 26.0G
    131029 12:53:36 InnoDB: Completed initialization of buffer pool
    131029 12:53:36 InnoDB: highest supported file format is Barracuda.
    131029 12:53:38  InnoDB: Waiting for the background threads to start
    131029 12:53:39 InnoDB: 5.5.34 started; log sequence number 5146431500
    131029 12:53:39 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
    131029 12:53:39 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
    131029 12:53:39 [Note] Server socket created on IP: '0.0.0.0'.
    131029 12:53:39 [Note] Event Scheduler: Loaded 0 events
    131029 12:53:39 [Note] /usr/sbin/mysqld: ready for connections.
    Version: '5.5.34-0ubuntu0.12.04.1-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

这是我第一次看到这个错误,我不知道如何解决这个问题,请在这里帮帮我。

谢谢

更新

好的,我尝试了glglgl的解决方案,重新启动后,我在错误日志中得到以下信息:

    131029 13:17:36 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be remo$
    131029 13:17:36 [Note] Plugin 'FEDERATED' is disabled.
    131029 13:17:36 InnoDB: The InnoDB memory heap is disabled
    131029 13:17:36 InnoDB: Mutexes and rw_locks use GCC atomic builtins
    131029 13:17:36 InnoDB: Compressed tables use zlib 1.2.3.4
    131029 13:17:36 InnoDB: Initializing buffer pool, size = 26.0G
    131029 13:17:38 InnoDB: Completed initialization of buffer pool
    131029 13:17:38 InnoDB: highest supported file format is Barracuda.
    131029 13:17:40  InnoDB: Waiting for the background threads to start
    131029 13:17:41 InnoDB: 5.5.34 started; log sequence number 5146431500
    131029 13:17:41 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
    131029 13:17:41 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
    131029 13:17:41 [Note] Server socket created on IP: '127.0.0.1'.  
    131029 13:17:41 [Note] Event Scheduler: Loaded 0 events
    131029 13:17:41 [Note] /usr/sbin/mysqld: ready for connections.
    Version: '5.5.34-0ubuntu0.12.04.1-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

最佳答案

检查进程是否在 Ubuntu 12.04 上运行,我的问题已解决

ps ax | grep mysql

然后答案是它没有运行,所以我运行了

sudo service mysql start

或者试试

sudo /etc/init.d/mysql start

关于mysql - 错误 2002 (HY000) : Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19658891/

相关文章:

mysql - SELECT INTO 和 "Undeclared variable"错误

php - 如何使用 laravel 连接 mysql?

mysql - 'LIKE ('%this%' OR '%that%' ) 和 something=

mysql - 如果另一列为空,则选择一列

php - 一次查询 MySQL 插入多行

c# - 将C#中的DateTime转换为yyyy-MM-dd格式并存储到MySql DateTim

mysql - 在 Postgresql 中模拟 MySQL 的 ORDER BY FIELD()

mysql - 将 Django DB 从 SQLite 迁移到 MySQL 的最佳方法是什么?

php - Doctrine2 迁移向下迁移并从浏览器而不是命令行迁移

mysql - 使用 mysql 查询获取字符串的最后 5 个字符