安装了mysql-5.7.17版本的community Server,因为Enterprenuer要花钱貌似。安装之后,启动发现有问题啊

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

然后查了一下看看究竟什么问题,/tmp/mysql.sock发现并没有这个文件啊,vim /etc/my.cnf 没有这个文件

最后想起来,貌似以前遇到这个问题,去找mac-偏好设置-mysql

在这里先start吧。

然后面板就显示

Mysql server status

the mysql database server is started and ready for client connections.

to shut the server down ,use the "stop mysql server" button.

the mysql server instance is running

if you stop the server,you and your applications will not

be able to  use mysql and all current connections will be closed.

Automaticaly started mysql server on startup

you may select to have the mysql server start 

automatically whenever your computer starts up.

发现还是不行,看来只有重设密码了

打开termimal

sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

Password:

2017-04-08T04:13:00.6NZ mysqld_safe Logging to '/usr/local/mysql/data/outofwall.local.err'.

Logging to '/usr/local/mysql/data/outofwall.local.err'.

2017-04-08T04:13:00.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

然后打开另一个终端

 sudo /usr/local/mysql/bin/mysql -u root
     UPDATE mysql.user SET authentication_string=PASSWORD('新密码') WHERE User='root';
     FLUSH PRIVILEGES;
     \q

4.  重启MySQL.

*以上方法针对 MySQL V5.7.9, 旧版的mysql请使用:UPDATE mysql.user SET Password=PASSWORD('新密码') WHERE User='root';