美文网首页工具使用
Homebrew安装和卸载MySql

Homebrew安装和卸载MySql

作者: lsh的学习笔记 | 来源:发表于2017-08-08 20:44 被阅读0次

安装

brew install mysql

安装的时候有显示一些信息

/usr/local/Cellar/mysql/8.0.19/bin/mysqld 
--initialize-insecure 
# 用户
--user=lsh 
# 安装目录
--basedir=/usr/local/Cellar/mysql/8.0.19 
# 数据文件目录
--datadir=/usr/local/var/mysql 
# 临时目录
--tmpdir=/tmp

设置密码

安装后会有如下提示,这里先后台启动再设置密码,这样好处有2个:

  1. 在设置密码时,可以更改密码等级为LOW等级。
  2. 可以解决Can't connect to local MySQL server through socket '/tmp/mysql.sock'问题。

总结的经验,怕遗忘。

# 设置密码
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
# 后台启动
To have launchd start mysql now and restart at login:
  brew services start mysql
# 简单启动
Or, if you don't want/need a background service you can just run:
  mysql.server start

执行mysql_secure_installation命令后,会有一个提示,这里只截取了每次停下来时的提示语。

# 输入root用户密码
Securing the MySQL server deployment.
# 使用空白密码连接(这里表示当前的连接状态)
Connecting to MySQL using a blank password.

# 验证密码组件可用于测试密码并提高安全性。它检查密码的强度并允许用户仅设置以下密码足够安全。您想设置“验证密码”组件吗?
VALIDATE PASSWORD COMPONENT 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 component?
 
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即可设置简单密码

# 请在此处设置root密码。
Please set the password for root here.
New password: 第一次输入密码
Re-enter new password: 重输入一次确认

# 删除匿名用户?
Remove anonymous users? (Press y|Y for Yes, any other key for No) : 我选y,其他的我没试过

# 禁止远程登录
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : 我选y,因为我只在笔记本使用

# 是否删除测试库
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 我选y,其他的我没试过

# 现在重新加载特权表
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : 我选y,其他的我没试过

开机自启

homebrew 安装好像会设置开机自启,我不是很喜欢,就关闭。

# 设置开机自启
# 1. 首先确认该目录是否存在,若已经存在不用执行本命令  
$ mkdir -p ~/Library/LaunchAgents   

# 2. 从mysql的安装目录下`/usr/local/Cellar/mysql/8.0.19`找到`homebrew.mxcl.mysql.plist`文件,并复制到~/Library/LaunchAgents目录下

# 3. 执行命令
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

# 关闭开机自启
# 1. 执行命令
$ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# 2. 删除
$ rm -f ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist  

一些命令

# 后台启动
brew services start mysql
# 启动
mysql.server start

# 连接
mysql -uroot -p

# 停止
mysql.server stop

# 重启
mysql.server restart

卸载MySql

brew uninstall mysql

相关文章

  • Homebrew安装和卸载MySql

    安装 安装的时候有显示一些信息 设置密码 安装后会有如下提示,这里先后台启动,再设置密码,这样好处有2个: 在设置...

  • mac 重装 mysql

    问题 mac 使用 Homebrew 安装 mysql , 默认安装的是最新版本, 和线上版本不一致. 因此卸载重...

  • Homebrew

    Homebrew 官网:https://brew.sh/ 安装 Homebrew 卸载 Homebrew

  • Mac下HomeBrew安装和卸载Mysql

    安装Mysql 设置MySql开机启动 启动Mysql 停止Mysql(设置了开机启动) 停止Mysql(未设置开...

  • 安装和卸载homebrew

    卸载/usr/bin/ruby -e "$(curl -fsSL https://raw.githubuserco...

  • HomeBrew 卸载和安装

    以下代码均是在终端操作 卸载 卸载之后可以通过下面代码检查是否卸载 安装 安装的中间会让输入一次密码,输入即可 以...

  • CocoaPods简便安装

    1. 简便安装 前提条件 Homebrew 中文官网 如何安装Homebrew? 如何卸载Homebrew? 如何...

  • [MAC] Homebrew的安装与使用

    安装Homebrew 卸载Homebrew Homebrew的使用 Homebrew的可执行命令是brew,其基本...

  • Homebrew

    先安装Homebrew (官方网址:https://brew.sh/) 卸载homebrew

  • 2019-09-26 MySQL5.7免安装版安装教程(完全卸载

    如果未完全卸载,点击以下链接 Windows完全卸载MySQL 注:安装MySQL分为安装版和免安装版,本次安装为...

网友评论

    本文标题:Homebrew安装和卸载MySql

    本文链接:https://www.haomeiwen.com/subject/mwsxrxtx.html