mac下用brew安裝 mysql

蘆夢宇發表於2018-12-14
  1. 通過homebrew安裝mysql,目前預設安裝最新版本,如果要安裝其他版本,需指定版本號
brew  install mysql@5.6
複製程式碼
  1. 修改配置檔案
vim /usr/local/etc/my.cnf

# Default Homebrew MySQL server config
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8

[mysqld]
collation-server = utf8_unicode_ci
character-set-server = utf8
init-connect ='SET NAMES utf8'
max_allowed_packet = 64M
bind-address = 127.0.0.1
port = 3306
socket = /tmp/mysql.sock
skip-grant-tables
複製程式碼
  1. 啟動服務
brew services start mysql@5.6 
brew services restart mysql@5.6  #重啟
brew services stop mysql@5.6     #停止
複製程式碼
  1. 連線資料庫
mysql -u root -p
複製程式碼

相關文章