我在Mac OS X Mountain Lion上安装了MySQL,但当我尝试MySQL -u root时,我得到了以下错误:
错误2002 (HY000):无法通过套接字/tmp/ MySQL连接到本地MySQL服务器。袜子”(2)
这个错误意味着什么?我该怎么解决呢?
我在Mac OS X Mountain Lion上安装了MySQL,但当我尝试MySQL -u root时,我得到了以下错误:
错误2002 (HY000):无法通过套接字/tmp/ MySQL连接到本地MySQL服务器。袜子”(2)
这个错误意味着什么?我该怎么解决呢?
当前回答
没有工作。我只是重新安装mysql(不要担心你的数据保持不变)。
然后开始使用
sudo mysql.server start
这是所有。酿造服务mysql启动不启动mysql。
MacOS Monterey上。
其他回答
对于我的例子,只需将host指定为127.0.0.1,而不是localhost:
$ bin/mysql -uroot -p -h127.0.0.1
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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>
如果你正在使用Kali linux,你可能需要显式地指定主机
用 Mysql -h 127.0.0.1 -u root 127.0.0.1是您的本地主机
试试这个
rm -rf /usr/local/var/mysql && brew postinstall mysql@5.7 && brew services restart mysql@5.7
我已经尝试了所有可能的方法来解决这个问题,比如ln -s /var/lib/mysql/mysql.袜子/ tmp / mysql。Sock,卸载并重新安装mysql,确保mysql在xampp上运行,但没有一个仍然工作。
最后,我打开my.cnf(配置文件)并复制套接字路径(确保复制完整路径,否则它将不起作用)。然后在我的终端中执行这个命令
mysql --socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
瞧,mysql启动了。
这个解决方案只会工作,如果你的MySQL显示在Xampp/Ampps上运行,但在终端它仍然没有连接到正确的套接字时,你已经尝试了类似的:
./mysql -u root
or
brew services start mysql
没有工作。我只是重新安装mysql(不要担心你的数据保持不变)。
然后开始使用
sudo mysql.server start
这是所有。酿造服务mysql启动不启动mysql。
MacOS Monterey上。