markdown 使用Homebrew在Sierra上安装MySQL

Posted

tags:

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

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

### 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 **5.7.15** as default formulae in its main repository :

* Enter the following command : `$ brew info mysql`  
* Expected output: **mysql: stable 5.7.15 (bottled)**

To install MySQL enter : `$ brew install mysql`
  

## Additional configuration
### Homebrew

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

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

* Verify the installed MySQL instance : `$ mysql -V`.   
Expected output : **Ver 14.14 Distrib 5.7.15, for osx10.12 (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` - instruction is equal to :   

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


https://www.memoinfo.fr/tutoriels-linux/guide-sauvegarde-restauration-mysql/

https://www.hivelocity.net/kb/using-mysql_upgrade-command/


Restore only one database from a dump
http://www.darrenmothersele.com/blog/2012/01/10/restore-single-db-from-complete-mysql-dump/

```
mysql -u root -p --one-database destdbname < alldatabases.sql
```

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

安装macOS high Sierr一直显示正在进行文件保险箱转换

markdown 使用Homebrew安装的pg和openssl在Mac上构建pgmodeler

markdown 在macOS Mojave上,rbenv install 2.6.1挂起“使用来自homebrew的realline”

markdown 使用Homebrew安装Apache 2.4和PHP 7.1

markdown Homebrew Cheat Sheet

markdown 卸载所有Homebrew和casks