Mac下Mysql启动异常["ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.so

1、在mac下使用安装mysql,启动的时候报如下错误

AnniedeMacBook-Pro:~ liuxm$ mysql -uroot
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

2、查看mysql的安装位置:

AnniedeMacBook-Pro:~ liuxm$ which mysql
/usr/local/bin/mysql
说明mysql还是安装过的

3、查看信息

AnniedeMacBook-Pro:~ liuxm$ brew info mysql
mysql: stable 5.7.18 (bottled)
Open source relational database management system
https://dev.mysql.com/doc/refman/5.7/en/
Conflicts with: mariadb, mariadb-connector-c, mysql-cluster, mysql-connector-c, percona-server
/usr/local/Cellar/mysql/5.7.18_1 (320 files, 232.9MB) *
Poured from bottle on 2017-09-05 at 17:32:05
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb
==> Dependencies
Build: cmake ✘
Required: openssl ✔
==> Requirements
Required: macOS >= 10.7 ✔
==> Options
–with-archive-storage-engine
Compile with the ARCHIVE storage engine enabled
–with-blackhole-storage-engine
Compile with the BLACKHOLE storage engine enabled
–with-debug
Build with debug support
–with-embedded
Build the embedded server
–with-local-infile
Build with local infile loading support
–with-test
Build with unit tests
==> Caveats
We’ve installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot

To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don’t want/need a background service you can just run:
mysql.server start

4、有可能mysql没有启动

AnniedeMacBook-Pro:~ liuxm$ mysql.server start
Starting MySQL
. SUCCESS!

启动后就没有这个问题

你可能感兴趣的:(mysql)