homebrew 是 macOS 缺失的軟件包管理器,譬如能夠下載 mysql、redis、wget 等等.操做系統:macOS High Sierra Version 10.14.5
Homebrew 會將軟件包安裝到獨立目錄,並將其文件軟連接至 /usr/local . Homebrew 不會將文件安裝到它自己目錄以外,因此您可將 Homebrew 安裝到任意位置.mysql
安裝命令,粘貼到終端git
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
https://brew.sh/github
brew doctor brew update brew install mysql brew info mysql
運行 brew service start mysql 能夠後臺啓動 mysql,運行 mysql.server start 前臺啓動 mysql(關閉控制檯,服務中止),當安裝完成以後須要進行一些設置redis
設置密碼需先啓動 mysql 服務sql
mysql_secure_installation
設置完以後測試一下vim
mysql -u root -p 123456
mkdir -p ~/Library/LaunchAgents ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents find /usr/local/Cellar/mysql/ -name "homebrew.mxcl.mysql.plist" -exec cp {} ~/Library/LaunchAgents/ \; launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
系統是按照以下順序進行 my.cnf 查找ruby
當前在 etc 下是存在一個 my.cnf 文件curl
cd /etc vim my.cnf
配置文件以下(略)socket
...... [client] default-character-set=utf8 #password = your_password port = 3306 socket = /tmp/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] character-set-server=utf8 init_connect='SET NAMES utf8 port = 3306 socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K ......
能夠改一些配置,修改完後 esc -> : -> wq 保存退出測試