Homebrew 是 macOS 系统自带的包管理器,相似于 CentOS 中的 yum
和 Ubuntu 的 apt-get
mysql
目前高版本的 macOS 系统中已经安装好了 Homebrew,输入git
brew doctor
复制代码
验证github
若是你的系统没有安装,输入如下命令 安装Homebrewsql
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
复制代码
安装完成以后数据库
brew doctor
确认 brew 能正常工做brew update
更新包Cakebrew 是 Homebrew 的一个图形化工具,能够更加直观对 Homebrew 进行管理,推荐安装ruby
安装也很简单去 www.cakebrew.com/ 这个网站下载安装包进行安装就好了,软件自带中文。bash
接下来就能够愉快的玩耍了curl
安装软件时可能会遇到没有权限访问目录的问题,能够按照 Cakebrew 的提示在终端输入如下命令编辑器
sudo chown -R wqlm /usr/local/share/man/man8
复制代码
如图,输入你要安装的软件,选择其中一个,点击上方的安装按钮,就开始安装了,因为我已经安装了 msyql@5.7 因此上面显示的是卸载ide
安装完以后咱们须要配置 msyql 的环境变量
cd ~
vi .bash_profile
i
切换到编辑模式PATH=/usr/local/opt/mysql@5.7/bin:$PATH
,/usr/local/opt/mysql@5.7/是你的安装目录:wq
,保存并退出vi编辑器source .bash_profile
使配置当即生效启动mysql服务
sudo mysql.server start
初始化mysql
sudo 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?
# 上面的意思是说你是否要为root设置密码,选择 y
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
# 这里要你选一个密码强度等级,0表示LOW,只要求你的密码长度大于8,因为我只是在本地玩玩,选择0
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: 25
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
... Failed! Error: Your password does not satisfy the current policy requirements
# 若是你设的密码没有知足 你所选的密码强度要求,它会让你重写设定密码
New password:
Re-enter new password:
Estimated strength of the password: 100
# 确认使用该密码吗,选择 y
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.
# 删除默认的匿名用户吗,选择 y
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.
# 禁止远程root登陆,我选的是no。由于我只是本地玩玩不会用于生产,也不会存什么敏感数据
Disallow root login remotely?
(Press y|Y for Yes, any other key for No) : no
... 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数据库吗,我选择 no
Remove test database and access to it?
(Press y|Y for Yes, any other key for No) : no
- 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.
# 是否让配置当即生效,选择 y
Reload privilege tables now?
(Press y|Y for Yes, any other key for No) : y
Success.
All done!
复制代码
设置完成以后,就能够经过 root 和刚刚设置的密码登录mysql了
mysql -u root -p
复制代码