2017-02-04 46 views
1

我已經閱讀了一些關於如何解決從終端啓動MySQL的問題的可能解決方案。沒有工作。MySQL不從Terminal,Mac OS El Capitan啓動;沒有找到解決方案

我的系統Mac OS El Capitan。

每當我試着開始從終端的MySQL,我得到這個錯誤:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 

如果我試圖讓通過瀏覽器來phpMyAdmin的連接,我輸入正確的用戶(root在我的情況)和密碼,我得到以下內容:

#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 

下面是有關該問題的非常簡要的信息,以及我檢查的內容。 試圖解決我做了如下問題:

(1)創建/etc文件夾中/usr/local/mysql

(2)複製my-default.cnf/usr/local/mysql/support-files, 的副本名爲my.cnf;移動my.cnf

/usr/local/mysql/etc 
directory 

但沒有無論如何更改文件,也沒有將其手動添加任何東西;所以它仍然有默認配置;

(3)在終端運行:

netstat -na |grep 3306 

tcp46  0  0 *.3306     *.*     LISTEN 

(4)比然:

ps aux | grep mysql 

得到這個:

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 

由此我看到,我有一個正確的user=_mysql

(5)試圖再次使用mysql -v -u root –p終端運行mysql,得到了相同的錯誤消息:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 

(6)我仍然可以得到它只能通過系統預置運行。 (7)由於上面顯示我有一個正確的用戶,所以我沒有運行sudo chown -R _mysql:_mysql /usr/local/var/mysql; 但我確實運行了sudo chown -R _mysql data/只是爲了它,儘管它沒有改變任何東西。

(8)去:cd /Library/LaunchDaemons 看到com.oracle.oss.mysql.mysqld.plist

sudo launchctl load -F com.oracle.oss.mysql.mysqld.plist 

透露,一切正常運行(這是當我通過系統首選項手動啓動MySQL的):

/Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist: service already loaded 

( 9)試着看com.oracle.oss.mysql.mysqld.plist的內容通過

sudo nano com.oracle.oss.mysql.mysqld.plist 

,這表明一些奇怪的(而不是HTML內容我已經隨處可見):

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$ 

我將是你的幫助非常感激! 非常感謝!

+0

請,有人能幫我解決這個問題。雖然我可以運行我的C程序,只要從系統偏好設置打開mysql,我不能通過終端或通過我的C程序進行連接,而C程序本質上就像通過終端連接一樣。看來我錯過了一些東西。當我通過'system preferences'連接時,我需要輸入我的電腦密碼(不是mysql的密碼),然後啓動mysql。儘管通過終端我不這樣做;我只輸入'mysql -v -u root -p'。非常感謝你! – Vitale

回答

0

我在Mac OSX Sierra上遇到了同樣的問題。 我結束了從恢復時間機器我com.oracle.oss.mysql.mysqld.plist它恢復到:

<?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> 
相關問題