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

最近重装了mac系统,所有常用的软件都需要重新安装一遍,无疑安装一个brew是个很好的选择,关于brew是什么,怎么安装建议去brew官网查看,附上地址:brew官网

安装完成之后,安装其他的软件就特别方便了。

执行:

 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
environment.

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


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
environment.


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

 - Removing privileges on test database...
Success.

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
Success.

All done! 

接下来启动mysql

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条评论