当前位置: 首页 > 知识库问答 >
问题:

错误2002(HY000):无法通过套接字“/var/run/mysqld/MySQL”连接到本地MySQL服务器。袜子(2)

艾璞瑜
2023-03-14

我犯了这个错误

ERROR 2002(HY000):无法通过socket'/var/run/mysqld/MySQL连接到本地MySQL服务器。袜子’(2)

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

mysql stop/waiting
mysql start/running, process 17691

然而,当试图访问该站点时,我会遇到一个数据库连接错误,当试图通过mysql-u root-p

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

    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)

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

谢谢

使现代化

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

    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)

共有3个答案

干旺
2023-03-14

我花了很长时间才弄明白,但你能试试同样的方法吗-

1-更新和升级

sudo apt-get update
sudo apt-get upgrade

2-清除MySQL服务器和客户端(如果安装)。

sudo apt-get purge mysql-server mysql-client

3-安装MySQL服务器和客户端新鲜

sudo apt-get install mysql-server mysql-client

4-测试MySQL

mysql -u root -p
> enter root password

***应该在/var/run/mysqld/mysql中找不到get套接字。短袜

4-配置mysqld。纳米六价碳纤维

sudo纳米 /etc/mysql/mysql.conf.d/mysqld.cnf

将绑定地址从127.0.0.1更改为localhost

bind-address            = localhost

**写入和退出

5-重启MySQL

sudo /etc/init.d/mysql restart

6-检查mysql

mysql -u root -p
> enter root password

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.13-0ubuntu0.16.04.2 (Ubuntu)

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

您现在应该进入mysql cli。

希望这有帮助

密码p0y

柴坚诚
2023-03-14

首先,请确认安装了mysql服务器。我有同样的错误,当mysql服务器安装,但损坏不知何故。我完全卸载mysql并重新安装它。

sudo apt-get remove --purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get install mysql-server mysql-client
汪安宁
2023-03-14

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

ps ax | grep mysql

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

sudo service mysql start

或尝试

sudo /etc/init.d/mysql start
 类似资料: