mac 安装mysql

一个简单的方式,利用homebrew包管理工具,假设你已经安装了homebrew
命令行输入brew install mysql
过程可能会比较久,成功后会有如下提示

➜  blog brew install mysql
Updating Homebrew...
^C^[[A==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.20.high_sierra.bottle.tar.g
######################################################################## 100.0%
==> Pouring mysql-5.7.20.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/mysql/5.7.20/bin/mysqld --initialize-insecure --user=liujinling --ba
==> Caveats
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
==> Summary
🍺  /usr/local/Cellar/mysql/5.7.20: 324 files, 233.7MB

根据绿色部分提示,我尝试mysql_secure_installation,但是报错

➜  blog mysql_secure_installation

Securing the MySQL server deployment.

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

由于初次尝试,并不了解mysql,去网上搜了很多类似错误解决办法,都比较复杂。于是抱着试试看的心态回头试了下绿色提示最后一个建议brew services start mysql

➜  blog brew services start mysql
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 17 (delta 0), reused 13 (delta 0), pack-reused 0
Unpacking objects: 100% (17/17), done.
Tapped 0 formulae (49 files, 59.0KB)
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)

看到Successfully着实安慰不小,接下来就该干嘛干嘛了,安装并启动成功!

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 网上搜索了很多安装 Mac 的文章,基本上介绍安装的方法有官网下载安装包安装 和 homebrew 命令行安装,我...
    雪樰阅读 386评论 0 0
  • MacBook-Air:~ huangyong$ brew install mysql ==> CaveatsWe...
    你说你要一场阅读 305评论 0 0
  • 1.安装Homebrew好不啦. 2.brew doctor 确认brew在正常工作. 3.brew update...
    冬什么冬阅读 388评论 0 0
  • 前言: 因为用mac开发,很多工具不是很熟练,这里做个笔记,以防以后再次入坑!!! 安装方式一:用dmg镜像安装 ...
    luckXiaofei阅读 82,643评论 4 32
  • 使用 brew 安装mysql 由于 HomeBrew 安装的 mysql 默认root账户没有设置密码。因此需要...
    我小时候可猛了_阅读 360评论 0 0