mac 通过brew 安装的mysql启动失败解决方案_weixin_33681778的博客-CSDN博客




 brew install mysql


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


unset TMPDIR
mysql_install_db --verbose --user=root --basedir="$(brew --prefix mysql)"--datadir=/usr/local/var/mysql --tmpdir=/tmp
修正 亲测可用
➜  5.7.31 mysql_install_db --verbose --user=root --basedir="$(brew --prefix mysql)"--datadir=/Users/linjinyu/MYSQL_HOME/data --tmpdir=/tmp
mysql_install_db: [ERROR] unknown variable 'tmpdir=/tmp'
2020-10-22 10:23:12 [ERROR]   Unrecognized options
➜  5.7.31 mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.

New password: 

Re-enter new password: 

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...

 - Removing privileges on test database...

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

All done! 


mysql.server start


mysql -uroot -p



mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mysql/5.6.16/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ #5.6.16是数据库版本号,根据你当时所安装的版本号自己修改
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist


MAC 10.11 OSX EI Brew安装环境问题汇总

Mysql 安装后无法link,执行”brew docker”报如下问题:

Error: The \`brew link\` step did not complete successfully

The formula built, but is not symlinked into/usr/local

Could notsymlinkshare/man/man8/mysqld.8

/usr/local/share/man/man8is not writable.


sudo chown-R  \`whoami\`/usr/local

原网址: 访问
创建于: 2020-10-22 09:55:50
目录: default
标签: 无

  • 最新评论
  • 总共0条评论