ERROR 2002 (HY000): Can#39;t connect to local MySQL server through socket #39;/var/run/mysqld/mysql.sock#39; (2)(ERROR 2002 (HY000): 无法通过 socket /var/run/mysqld/mysql.sock 连接到本地 MySQL 服务器 (2))
问题描述
我收到此错误
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2)
即使我已经设法在 ubuntu 中通过命令行启动了 mysql
even though I have managed to start mysql via command line in ubuntu
mysql stop/waiting
mysql start/running, process 17691
但是,当我尝试访问该站点时,出现数据库连接错误以及尝试通过 mysql -u root -p
However when attempting to access the site I get a database connection error as well as the above error when trying to access mysql via mysql -u root -p
我检查了我的错误日志,我看到了这个
I checked my error logs and I saw this
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)
这是我第一次看到这个错误,我不知道如何解决这个问题,请在这里帮助我.
It's the first time I see this error and I'm not sure how to solve this issue, please help me out a bit here.
谢谢
更新
好的,我尝试了 glglgl 的解决方案,重新启动后,我在错误日志中看到以下内容:
Okay I tried glglgl's solution and after a restart, I get the following in the error log:
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 上运行时我的问题已解决
My problem was solved checking if the process was running on Ubuntu 12.04
ps ax | grep mysql
然后答案是它没有运行,所以我运行了
Then the answer was that it wasn't running, so I did
sudo service mysql start
或者试试
sudo /etc/init.d/mysql start
这篇关于ERROR 2002 (HY000): 无法通过 socket '/var/run/mysqld/mysql.sock' 连接到本地 MySQL 服务器 (2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ERROR 2002 (HY000): 无法通过 socket '/var/run/mysqld/mysql.sock' 连接到本地 MySQL 服务器 (2)
基础教程推荐
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01