插座坏了;无法使用Laravel登录MySQL


Broken socket & unable to log into MySQL with Laravel

我已经尝试了所有其他解决方案,以修复Laravel如何连接到MySQL,到我已经打破了我的插座的地步。我的第一个错误是我无法使用localhost登录。然后我开始摆弄插座。现在,即使使用127.0.0.1而不是localhost,也会出现以下错误:

PDOException in Connector.php line 50:
SQLSTATE[HY000] [2002] Socket operation on non-socket
in Connector.php line 50
at PDO->__construct('mysql:unix_socket=/var/mysql/mysql.sock;dbname=databasename', 'root', 'notroot', array('0', '2', '0', false, '0')) in Connector.php line 50
at Connector->createConnection('mysql:unix_socket=/var/mysql/mysql.sock;dbname=databasename', array('driver' => 'mysql', 'host' => '127.0.0.1', 'unix_socket' => '/var/mysql/mysql.sock', 'database' => 'databasename', 'username' => 'root', 'password' => 'notroot', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, '0')) in MySqlConnector.php line 22

这怎么可能?如果我不使用localhost连接,怎么可能涉及到套接字?我已经尝试了很多东西,我认为我需要重新安装一堆东西在这一点上,但我不想失去我的数据库。如何在没有任何工具的情况下备份数据库(Sequel Pro不再工作)?

好的,我可以通过重新安装MAMP Pro来做到这一点。我实际上需要升级到3.4,所以我做了。当我进入WebStart时,我看到套接字位于/Applications/MAMP/tmp/mysql/mysql。sock,所以我在Sequel Pro和我的Laravel unix socket属性在database.php中改变了我的行,它修复了一切。