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

无法通过Ubuntu 12.04.5LTS中的套接字“/var/run/mysqld/mysqld.sock”连接到本地MySQL服务器

宦博超
2023-03-14

我在Ubuntu 12.04.5LTS中遇到了无法通过套接字“/var/run/mysqld/mysqld.sock”连接到本地MySQL服务器的错误。因此,我从Ubuntu 12.04.5 LTS卸载了MySQL5.5,但当我试图安装mysql时,我无法安装mysql。

 sudo apt-get remove --purge mysql-server mysql-client mysql-common
 sudo apt-get remove --purge mysql-server-5.5 mysql-client-5.5 mysql-servercore-5.5 mysql-client-core-5.5
 sudo apt-get autoremove
 sudo apt-get autoclean
 sudo rm -rf /var/lib/mysql
 sudo rm -rf /etc/mysql
 sudo deluser mysql
sudo apt-get install mysql-server-5.5
sudo apt-get install mysql-server

但是我遇到了以下错误:

 AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in      /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql'
 start: Job failed to start
 invoke-rc.d: initscript mysql, action "start" failed.
 dpkg: error processing mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.
dpkg: error processing mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup    error from a previous failure.
                                                                                                         Errors were encountered while processing:
mysql-server-5.5
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

当我从终端输入'mysql'时,它返回错误:

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

我在谷歌搜索后尝试telnet 127.0.0.13306,它返回连接拒绝。

共有1个答案

秦伯寅
2023-03-14

这是我和Mariadb的安排

首先了解您的mysql配置文件(最有可能位于/etc/mysql/my.cnf/etc/my.cnf中)是否具有正确的mysql.sock条目

您可以通过运行find/-type s来查找mysql.sock文件的位置,如果该条目在mysql配置中不正确,请将其文件修复,同时确保mysql.pid的路径也是正确的。

现在尝试启动mysql server,如果它启动良好,并且可以看到里面的所有数据库和表,那么您就很好了,不需要继续后面的内容。

如果修复mysql.sock路径后mysql无法启动,请继续阅读

将以下内容添加到My.cnfhtml" target="_blank">文件中,

帮助我的帖子

  • https://stackoverflow.com/a/20617180/3117013
  • https://stackoverflow.com/a/11990813/3117013
 类似资料: