安装命令:

brew install mysql

安装完成之后,启动mysql:

mysql.server start

发现无此命令:

command not found

首先,检查是否是安装了。重新执行一遍:

brew install mysql

提示:

Warning: mysql-5.7.17 already installed, it's just not linked

然后网上查找解决方法,执行:

brew link --overwrite mysql

报错:

Linking /usr/local/Cellar/mysql/5.7.17...
    Error: Could not symlink share/man/man8/mysqld.8 /usr/local/share/man/man8 is not writable.

查找解决方法,以下语句执行成功:

sudo chown -R 'username' /usr/local

解决了问题后,重新执行:

brew link --overwrite mysql

提示:
    Linking /usr/local/Cellar/mysql/5.7.17... 93 symlinks created

重新执行:

mysql.server start

没有错误。表示这时我们已经启动mysql服务器,按照brew的提示设置管理员密码。

mysql_secure_installation

然后根据提示操作就好了,以下代码来自文献[1]。

 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 >=
MEDIUM Length >= , numeric, mixed case, and special characters
STRONG Length >= , numeric, mixed case, special characters and dictionary file
// 这里提示选一个密码强度等级
Please enter = LOW, = MEDIUM and = STRONG:
Please set the password for root here.
// 然后按照所选的密码强度要求设定密码
New password: Re-enter new password: Estimated strength of the password:
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:
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.
// 禁止远程root登录,我选的是不禁止。因为我的mac上的数据库不会放到公网上,也不会存什么敏感数据
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数据库
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 -r root -p

输入密码,成功进入:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 5.7.17 Homebrew

测试一下:

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.03 sec)

全部

使用Homebrew安装MySQL的更多相关文章

  1. mac系统homebrew安装mysql

    homebrew 安装 mysql homebrew 是 macOS 缺失的软件包管理器,譬如可以下载 mysql.redis.wget 等等.操作系统:macOS High Sierra Versi ...

  2. Homebrew 安装 MySQL

    安装 Homebrew brew doctor 确认 brew 在正常工作 brew update 更新包 brew install mysql 安装 MySQL ​ ==> Downloadi ...

  3. mac 使用homebrew 安装mysql

    1. 安装homebrew ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" brew update ...

  4. Mac下 homebrew 安装mysql

    操作步骤 安装homebrew brew install mysql 安装mysql 安装完成之后,可以运行命令启动mysql服务 mysql.server start 然后输入命令设置密码 mysq ...

  5. Mac通过homebrew 安装mysql

    来源:http://timtang.me/blog/2011/12/07/mac-homebrew-mysql/ 使用MBP有一年了,开始想在工作中使用mac由于各种不习惯最终失败,导致自己使用了一年 ...

  6. Homebrew 安装mysql

    在mac上安装软件,无疑安装一个brew是个很好的选择,关于brew是什么,怎么安装建议去brew官网查看, 附上地址:brew官网  还有一篇博文 http://www.cnblogs.com/xd ...

  7. Mysql学习(四)之通过homebrew安装mysql后,为什么在系统偏好设置里没有mysql

    原因 用brew install packagename是用来安装命令行工具的,一般不可能影响到图形界面. mysql官方文档是通过dmg文件安装的: The MySQL Installation P ...

  8. Mysql学习(二)之通过homebrew安装mysql后,为什么在系统偏好设置里没有mysql

    原因 用brew install packagename是用来安装命令行工具的,一般不可能影响到图形界面. mysql官方文档是通过dmg文件安装的: The MySQL Installation P ...

  9. Mac 命令行安装mysql homebrew 安装mysql后,如何配置mysql

    非常好 强力推荐 这个是我最新并且一直推崇的方法:1.安装:sunyichaodeMacBook-Pro:~ sunyichao$ brew install mysql2.开启mysql:mysql. ...

随机推荐

  1. Day4-生成器generator

    列表生成式 需求:列表[0,1,2,3,4,5,6,7,8,9]每个值加1,如何实现? 方法1:列表追加 >>> a = [0,1,2,3,4,5,6,7,8,9] >> ...

  2. Python正则表达式完全指南(上)

    正则表达式处理文本有如疾风扫秋叶,绝大部分编程语言都内置支持正则表达式,它应用在诸如表单验证.文本提取.替换等场景.爬虫系统更是离不开正则表达式,用好正则表达式往往能收到事半功倍的效果. 介绍正则表达 ...

  3. python 字符串常用方法

    字符串常用方法 capitalize() String.capitalize() 将字符串首字母变为大写 name = 'xiaoming' new_name = name.capitalize() ...

  4. 从矩阵的定义开始谈OpenGL矩阵变换

    前言 最近自己想用C语言写一个Minecraft clone(GitHub链接:http://github.com/CharlesDong/m3c/),因为是现代OpenGL,又是C语言,GLM用不了 ...

  5. javaSE_07Java中类和对象-封装特性--练习

    1.编写封装一个学生类,有姓名,有年龄,有性别,有英语成绩,数学成绩,语文成绩,一个学生类,我们关注姓名,年龄,学历等信息,要求年龄必须在19-40岁之间,默认为19,学历必须是大专,本科,研究生这几 ...

  6. 导入java项目时出现红色叹号问题的解决

    问题:导入java项目时出现红色叹号(如下图所示) 原因:引入项目的某些jar包跟自己电脑上的位置不一样: 解决方案:步骤如下 (1)右键红色叹号所在项目————>build path————& ...

  7. 利用npm安装/删除/发布/更新/撤销发布包 --社会我npm哥,好用话不多

      一.什么是npm? npm是javascript的包管理工具,是前端模块化下的一个标志性产物 简单地地说,就是通过npm下载模块,复用已有的代码,提高工作效率   1.从社区的角度:把针对某一特定 ...

  8. linux shell编程-bash的奇技淫巧

    本文主要讲bash脚本中容易出错和很少用但是用起来有意想不到效果的部分. 循环: 正常的for循环: for i in a b c 1 2 3; do echo "$i" done ...

  9. 自己整理的openresty安装步骤

    这几天一直在研究对webapi的限流和名单的问题,于是看了开涛博客的方案,于是就用到了openresty,一个把Nginx和lua集成的东西. 下面就是整理的安装方案(简单使用基本可以这么安装) 下载 ...

  10. 模拟jquery底层链式编程

    //特点1:快级作用域,程序启动自动执行 //内部的成员变量,外部无法访问(除了var) //简单的函数链式调用 function Dog(){ this.run=function(){ alert( ...