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!

启动后就没有这个问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值