无法通过套接字“/opt/local/var/run/percona/mysqld.sock”连接到本地MySQL服务器

我已经安装percona服务器在我的Mac机上使用macports,但是我正在运行到上面的sockets错误,如下所示:

Sauds-MacBook-Pro:percona jini$ sudo /opt/local/lib/percona/bin/mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/percona/mysqld.sock' (2) 

怪异的部分是,我可以连接到MySQL的命令行和使用PHP。 只是当我尝试运行上面的命令,它是失败的。

以下是my.cnf的内容:

 [mysql] # CLIENT # port = 3306 socket = /opt/local/var/db/percona/mysql.sock [mysqld] # GENERAL # user = mysql default-storage-engine = InnoDB socket = /opt/local/var/db/percona/mysql.sock pid-file = /opt/local/var/db/percona/mysql.pid # MyISAM # key-buffer-size = 32M myisam-recover = FORCE,BACKUP # SAFETY # max-allowed-packet = 16M max-connect-errors = 1000000 # DATA STORAGE # datadir = /opt/local/var/db/percona/ # CACHES AND LIMITS # tmp-table-size = 32M max-heap-table-size = 32M query-cache-type = 0 query-cache-size = 0 max-connections = 10 thread-cache-size = 16 open-files-limit = 65535 table-definition-cache = 1024 table-open-cache = 2048 # INNODB # innodb-flush-method = O_DIRECT innodb-log-files-in-group = 2 innodb-log-file-size = 5M innodb-flush-log-at-trx-commit = 2 innodb-file-per-table = 1 innodb-buffer-pool-size = 12G # LOGGING # log-error = /opt/local/var/db/percona/mysql-error.log log-queries-not-using-indexes = 1 slow-query-log = 1 slow-query-log-file = /opt/local/var/db/percona/mysql-slow.log 

正如你所看到的,我没有在任何地方引用“opt / local / var / run / percona / mysqld.sock”,它仍然试图在那里寻找文件。

我只看到列在/ opt / local / var / db / percona的mysql.sock

 srwxrwxrwx 1 _mysql _mysql 0 Jan 24 06:37 mysql.sock 

另请参阅:

 Sauds-MacBook-Pro:percona jini$ mysql_config --socket /opt/local/var/run/percona/mysqld.sock 

为什么它试图find“/opt/local/var/run/percona/mysqld.sock”等等,为什么我得到这个错误?

更新:所以,如果我创build一个符号链接:

 sudo ln -s /opt/local/var/db/percona/mysql.sock /opt/local/var/run/percona/mysqld.sock 

一切正常。 但是,我仍然没有答案,为什么我没有一个mysqld.sock文件。

my.cnf可以位于几个不同的地方,有些则优先于其他地方。 看看他们可能在哪里https://stackoverflow.com/questions/2482234/how-to-know-mysql-my-cnf-location 。 如果你有另一个my.cnf位于某处,那么可能是从那里拉取configuration。