I have read a few possible solutions on how to fix the problem with starting MySQL from the terminal. None has worked.
My system Mac OS El Capitan.
Whenever I try to start mysql from Terminal, I get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
If I try to get connected via browser to phpmyadmin, I enter a correct user (root in my case) and a password, I get the following:
#2002 - No such file or directory — The server is not responding (or the local server's socket is not correctly configured).
mysqli_real_connect(): (HY000/2002): No such file or directory
Here is very briefly information on the problem, and what I have checked. Trying to solve the issue I did the following:
(1) have created /etc
folder in /usr/local/mysql
(2) copied my-default.cnf
in /usr/local/mysql/support-files
, the copy is named my.cnf
; moved my.cnf
to
/usr/local/mysql/etc
directory
but didn't change the file anyhow, didn't add anything to it manually; so it still have default configurations;
(3) ran in terminal:
netstat -na |grep 3306
tcp46 0 0 *.3306 *.* LISTEN
(4) than ran:
ps aux | grep mysql
got this:
mynamehere 2575 1.3 0.0 2444056 824 s000 S+ 12:29PM 0:00.01 grep mysql
_mysql 989 0.0 0.2 2893920 8896 ?? Ss 10:21AM 0:04.62 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid
From this I see that I have a correct user=_mysql
(5) tried again to run mysql from the terminal using mysql -v -u root –p
, got the same error message:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
(6) I still can get it running only via System Preferences .
(7) As the above revealed I have a correct user, so I didn't run sudo chown -R _mysql:_mysql /usr/local/var/mysql
; but I did run sudo chown -R _mysql data/
just for the sake of it, though it didn't change anything.
(8) went to: cd /Library/LaunchDaemons
to see com.oracle.oss.mysql.mysqld.plist
sudo launchctl load -F com.oracle.oss.mysql.mysqld.plist
revealed that everything is running ok (this was when I have manually started mysql via system preferences):
/Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist: service already loaded
(9) tried to see the contents of com.oracle.oss.mysql.mysqld.plist
by
sudo nano com.oracle.oss.mysql.mysqld.plist
and this showed something bizarre (not the html content I have seen everywhere):
bplist00�^A^B^C^D^E^F^G^H
^K^L
^N^O^P^Q^Q^Q^T^P^U^V^Q^W^_[ExitTimeOut_^P^PWorkingDirectoryYGroupNameXDisabledY$
I will be truly grateful for your help! Thank you very much!
I had the same problem on Mac OSX Sierra. I ended up restoring my com.oracle.oss.mysql.mysqld.plist from TimeMachine which restored it to:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key> <string>com.oracle.oss.mysql.mysqld</string>
<key>ProcessType</key> <string>Interactive</string>
<key>Disabled</key> <false/>
<key>RunAtLoad</key> <true/>
<key>KeepAlive</key> <true/>
<key>SessionCreate</key> <true/>
<key>LaunchOnlyOnce</key> <false/>
<key>UserName</key> <string>_mysql</string>
<key>GroupName</key> <string>_mysql</string>
<key>ExitTimeOut</key> <integer>600</integer>
<key>Program</key> <string>/usr/local/mysql/bin/mysqld</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld</string>
<string>--user=_mysql</string>
<string>--basedir=/usr/local/mysql</string>
<string>--datadir=/usr/local/mysql/data</string>
<string>--plugin-dir=/usr/local/mysql/lib/plugin</string>
<string>--log-error=/usr/local/mysql/data/mysqld.local.err</string>
<string>--pid-file=/usr/local/mysql/data/mysqld.local.pid</string>
<string>--keyring-file-data=/usr/local/mysql/keyring/keyring</string>
<string>--early-plugin-load=keyring_file=keyring_file.so</string>
</array>
<key>WorkingDirectory</key> <string>/usr/local/mysql</string>
</dict>
</plist>
在com.oracle.oss.mysql.mysqld.plist
RunAtLoad
和KeepAlive
设置为<true />
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.