- 通過homebrew安裝mysql,目前預設安裝最新版本,如果要安裝其他版本,需指定版本號
brew install mysql@5.6
複製程式碼
- 修改配置檔案
vim /usr/local/etc/my.cnf
[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
複製程式碼
- 啟動服務
brew services start mysql@5.6
brew services restart mysql@5.6
brew services stop mysql@5.6
複製程式碼
- 連線資料庫
mysql -u root -p
複製程式碼