[英]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")
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>时,它给了我这个错误:
I have mariadb that I've installed from https:\/\/mariadb.org\/<\/a>我有从https:\/\/mariadb.org\/<\/a>安装的 mariadb
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>文件)
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.