markdown 使用Homebrew在macOS上安装MySQL 5.7

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 使用Homebrew在macOS上安装MySQL 5.7相关的知识,希望对你有一定的参考价值。

> This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

## Install MySQL 5.7 on macOS
This procedure explains how to install [MySQL](https://www.mysql.com) using [Homebrew](http://brew.sh) on macOS (Sierra 10.12 and up)

### Install Homebrew
* Installing Homebrew is effortless, open Terminal and enter :  
 `$  /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
* **Note:** Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

### Install MySQL
At this time of writing, Homebrew has MySQL version **8** as default, but as we're aiming to get **5.7**, we'll need to append `@5.7` to the default package key:

* Enter the following command : `$ brew info mysql@5.7`  
* Expected output: **mysql@5.7: stable 5.7.22 (bottled) [keg-only]**

To install MySQL enter : `$ brew install mysql@5.7`

## Additional configuration
### Homebrew

* Install **brew services** first : `$ brew tap homebrew/services`
* Load and start the MySQL service : `$ brew services start mysql@5.7`.   
Expected output : **Successfully started `mysql` (label: homebrew.mxcl.mysql)** 	  

* Check of the MySQL service has been loaded : `$ brew services list` <sup>[1](#1)</sup>

* Force link 5.7 version - `$ brew link mysql@5.7 --force` 
* Verify the installed MySQL instance : `$ mysql -V`.   
Expected output : **Ver 14.14 Distrib 5.7.22, for osx10.13 (x86_64)**  


### MySQL
Open Terminal and execute the following command to set the root password:  
 `mysqladmin -u root password 'yourpassword'`  

> **Important** : Use the single ‘quotes’ to surround the password and make sure to select a strong password! 

### Database Management
To manage your databases, I recommend using [Sequel Pro](http://www.sequelpro.com), a MySQL management tool designed for macOS.   
Current version available: **1.1.2**


##### Comments
<a name="1"><sup>1</sup></a> The `brew services start mysql@5.7` - instruction is equal to :   

```
$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
```

以上是关于markdown 使用Homebrew在macOS上安装MySQL 5.7的主要内容,如果未能解决你的问题,请参考以下文章

markdown Instalasi php 7.1 di MacOS menggunakan homebrew

macOS安装Homebrew

如何使用 homebrew 在 MACOS 中安装 node.js

通过 Homebrew 在 MacOS 上使用 asdf 安装 ruby

MacOS使用HomeBrew安装Docker

如何在多用户 MacOS Sierra 设置中使用 Homebrew