简体   繁体   English

"Can't find mysqld.sock: Can't connect to local MySQL server through socket '\/var\/run\/mysqld\/mysqld.sock' (2 "No such file or directory")"

[英]Can't find mysqld.sock: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

I've just registered to Stack Overflow because I really can't get out of this problem since 2 days ago.我刚刚注册到 Stack Overflow,因为从 2 天前开始我真的无法摆脱这个问题。 I use Xampp.我使用 Xampp。<\/h2>

So, I'm following this Laravel tutorial<\/a> and when from the terminal I type in the project directory or every elsewhere directory mysql<\/em><\/strong> or mysql -uroot -p<\/em><\/strong> it gives me this error:所以,我正在关注这个 Laravel 教程<\/a>,当我从终端输入项目目录或每个其他目录mysql<\/em><\/strong>或mysql -uroot -p<\/em><\/strong>时,它给了我这个错误:

Can't connect to local MySQL server through socket '\/var\/run\/mysqld\/mysqld.sock' (2 "No such file or directory")<\/em><\/strong>无法通过套接字'\/var\/run\/mysqld\/mysqld.sock'连接到本地MySQL服务器(2“没有这样的文件或目录”)<\/em><\/strong>

I have mariadb that I've installed from https:\/\/mariadb.org\/<\/a>我有从https:\/\/mariadb.org\/<\/a>安装的 mariadb

My OS is Ubuntu 16.04 LTS ( here I typed lsb_release -a ) No LSB modules are available.<\/strong>我的操作系统是 Ubuntu 16.04 LTS(在这里我输入了 lsb_release -a )没有可用的 LSB 模块。<\/strong> Distributor ID: Ubuntu Description: Ubuntu 16.04.2 LTS Release: 16.04 Codename: xenial<\/strong>发行商 ID:Ubuntu 描述:Ubuntu 16.04.2 LTS 版本:16.04 代号:xenial<\/strong>

By doing cd \/var\/run\/<\/strong> and then ll<\/strong> I discovered that the directory \/var\/run\/mysqld<\/strong> doesn't exist, and the mysql.sock file neither.通过执行cd \/var\/run\/<\/strong>然后ll<\/strong>我发现目录\/var\/run\/mysqld<\/strong>不存在,mysql.sock 文件也不存在。

So I googled a bit and I found this<\/a> where they talk about the \/etc\/my.cnf<\/strong> file but I discovered by doing some cd<\/strong> commands that I don't have even this file.所以我用谷歌搜索了一下,我发现这<\/a>是他们谈论\/etc\/my.cnf<\/strong>文件的地方,但我通过执行一些cd<\/strong>命令发现我什至没有这个文件。 ( But I've just noticed that I have a \/etc\/mysql\/my.cnf<\/strong> and \/etc\/mysql\/my.cnf.fallback<\/strong> file ) (但我刚刚注意到我有一个\/etc\/mysql\/my.cnf<\/strong>和\/etc\/mysql\/my.cnf.fallback<\/strong>文件)

Anithing else ?还有什么? Oh, yes.哦是的。 Uninstalling mariadb and installing mysql would not resolve the problem because I have issues with the dpkg packages.卸载 mariadb 并安装 mysql 并不能解决问题,因为我的 dpkg 包有问题。

I also tried a lot of times installing and uninstalling xamp, laravel dir, mysql, mariadb...我也尝试了很多次安装和卸载 xamp、laravel dir、mysql、mariadb ......

I don't really know what to do.我真的不知道该怎么办。 :((( :(((

"

I got it!我知道了! So, first I removed every trace of MariaDB with these commands:因此,首先我使用以下命令删除了 MariaDB 的所有痕迹:

sudo service mysql stop
sudo apt-get --purge remove "mysql*
sudo rm -rf /etc/mysql/ 

When you use localhost to connect to MySQL, the operating system uses the socket connector.当您使用localhost连接到 MySQL 时,操作系统使用套接字连接器。 However, if you use the 127.0.0.1 IP address, the operating system will use the TCP/IP connector.但是,如果您使用127.0.0.1 IP 地址,操作系统将使用 TCP/IP 连接器。 So, a possible solution when you're having issues with the socket connector is trying to establish the connection using TCP/IP by specifying the 127.0.0.1 IP address instead of localhost .因此,当您遇到套接字连接器问题时,一个可能的解决方案是尝试通过指定127.0.0.1 IP 地址而不是localhost来使用 TCP/IP 建立连接。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mysql错误“无法通过套接字&#39;/var/run/mysqld/mysqld.sock连接到本地MySQL服务器” - mysql error “Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock” 无法通过ubuntu 14.04中的套接字&#39;/var/run/mysqld/mysqld.sock&#39;(2)连接到本地MySQL服务器 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in ubuntu 14.04 “无法通过套接字&#39;/var/run/mysqld/mysqld.sock&#39;(2)连接到本地MySQL服务器”) - “Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)”) django无法通过套接字&#39;/var/run/mysqld/mysqld.sock连接到本地MySQL服务器 - django Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock OperationalError: (2002, &quot;Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39; (2)&quot;) - OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") Ubuntu:无法通过套接字&#39;/var/run/mysqld/mysqld.sock&#39;连接到本地MySQL服务器(2) - Ubuntu: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 无法通过套接字&#39;/var/run/mysqld/mysqld.sock&#39;(2)连接到本地MySQL服务器(错误2002) - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) (error 2002) 问题:无法通过套接字&#39;/var/run/mysqld/mysqld.sock&#39;(2)连接到本地MySQL服务器 - Problem:: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 无法通过套接字&#39;/var/run/mysqld/mysqld.sock&#39;连接到本地MySQL服务器 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' WSL:无法通过套接字&#39;/var/run/mysqld/mysqld.sock&#39;连接到本地MySQL服务器(2) - WSL: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM