Welcome everyone

brew安装mysql

mysql 汪明鑫 1002浏览 0评论

在mac使用brew安装mysql

 

Homebrew

什么是Homebrew呢?Homebrew is the easiest and most flexible way to install the UNIX tools Apple didn’t include with OS X. 官方的解释非常明了,Homebrew是一个包管理器,用于在Mac上安装一些OS X没有的UNIX工具(比如著名的wget)。

Homebrew将这些工具统统安装到了 /usr/local/Cellar 目录中,并在 /usr/local/bin 中创建符号链接。

 

官方网站:

http://mxcl.github.com/homebrew/

 

安装brew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

 

 

安装mysql

brew install mysql@5.7 

 

We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have mysql@5.7 first in your PATH run:
  echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile

For compilers to find mysql@5.7 you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
  export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"


To have launchd start mysql@5.7 now and restart at login:
  brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/mysql@5.7/bin/mysql.server start
==> Summary
🍺  /usr/local/Cellar/mysql@5.7/5.7.26: 320 files, 231.8MB

 

让你跑 mysql_secure_installation

前往路径 : /usr/local/Cellar/mysql@5.7/5.7.26/bin

通过brew安装的软件都在Cellar这个路径下

执行  mysql_secure_installation

 

结果报错:

 

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

 

原因:未启动mysql

先启动mysql   mysql.server start

再执行 mysql_secure_installation

 

设置密码等:

cometdeMacBook-Pro:~ comet
$ 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?
 // 这个选yes的话密码长度就必须要设置为8位以上,但我只想要6位的
Press y|Y for Yes, any other key for No: N   
Please set the password for root here.
 
New password:            // 设置密码
 
Re-enter new password:     // 再一次确认密码
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.
 
 // 是否删除test库
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:brew services start mysql@5.7
停止mysql:brew services stop mysql@5.7

 

转载请注明:汪明鑫的个人博客 » brew安装mysql

喜欢 (0)

说点什么

您将是第一位评论人!

提醒
avatar
wpDiscuz