Mac通过homebrew 安装mysql
通过brew安装mysql:
brew install mysql
等成功安装完成,想要登录的时候出问题了:
ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2)
google了一下,找到答案原来,还没彻底安装完成:
brew info mysql
可以看到如下命令,执行之:
ln -sfv /usr/local/opt/mysql/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents
下面我们还需要启动mysql服务:
mysql.server start
用如下命令登录即可:
mysql -uroot #初始没有设置密码
mysql 修改root密码
$ mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("NEWPASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
done!