MySQL不是从终端,Mac OS El Capitan开始的;找不到任何解决方案

时间:2017-02-04 09:57:28

标签: mysql macos osx-elcapitan

我已经阅读了一些关于如何解决从终端启动MySQL的问题的可能解决方案。没有人工作过。

我的系统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/LaunchDaemonscom.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$

我将非常感谢你的帮助! 非常感谢你!

2 个答案:

答案 0 :(得分:0)

我在Mac OSX Sierra上遇到了同样的问题。 我最终从TimeMachine恢复了我的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>

答案 1 :(得分:0)

$username = "username" $password = "password" $credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @("soft\abbas_104",(ConvertTo-SecureString -String "Abbas1122" -AsPlainText -Force)) Start-Process -PassThru -FilePath powershell -Credential $credentials -ArgumentList '-noprofile -command &{Start-Process ', cmd, ' -Wait -verb runas}' 上,将 com.oracle.oss.mysql.mysqld.plistRunAtLoad 设置为 KeepAlive