2、检查是否是安装了:brew install mysql
touch: /usr/local/Homebrew/.git/FETCH_HEAD: Permission denied
fatal: Unable to create ‘/usr/local/Homebrew/.git/index.lock’: Permission denied
error: could not lock config file .git/config: Permission denied
Cannot rebase: You have unstaged changes.
Please commit or stash them.
Warning: mysql-5.7.18_1 already installed, it’s just not linked
3、解决方法是执行:brew link –overwrite mysql
Linking /usr/local/Cellar/mysql/5.7.18_1…
Error: Could not symlink share/man/man8/mysqld.8
/usr/local/share/man/man8 is not writable.
依然报错
4、最后执行语句成功: sudo chown -R ‘username’ /usr/local
username是电脑名
5、重新执行:brew link –overwrite mysql
提示:
Linking /usr/local/Cellar/mysql/5.7.18_1… 93 symlinks created
6、执行:mysql -u root -p
报如下错误
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
7、依次执行:
unset TMPDIR
bash mysql_install_db –verbose –user=root
–basedir=”$(brew –prefix mysql)”–datadir=/usr/local/var/mysql –tmpdir=/tmp
8、启动mysql
bash mysql.server start
9、登录: mysql -uroot
常用命令:
mysql.server start
mysql.server restart
mysql.server stop
mysql.server status
mysql -u root -p