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

前端 未结 30 1298
南旧
南旧 2020-12-04 05:14

I installed MySQL on Mac OS X Mountain Lion with homebrew install mysql, but when I tried mysql -u root I got the following error:

30条回答
  •  执笔经年
    2020-12-04 05:54

    Encountered a similar problem after upgrading to Catalina OS. After running mysqld command, I found that there was some issue with the logs file. It could be different for others.

    $ mysqld
    

    Issue was

    2019-10-16T04:58:59.174474Z 0 [ERROR] Could not open file '/var/log/mysql/error.log' for error logging: No such file or directory
    2019-10-16T04:58:59.174508Z 0 [ERROR] Aborting
    

    Resolved it by creating it and applying proper permissions.

    sudo mkdir -p /var/log/mysql
    sudo touch /var/log/mysql/error.log
    sudo chown -R _mysql:mysql /var/log/mysql/
    

    Restart MySQL

    brew services restart mysql@5.7
    

    Issue was resolved.

    mysql -uroot -proot
    

提交回复
热议问题