阅读 3004

mac下用brew安装 mysql

  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
复制代码
关注下面的标签,发现更多相似文章
评论