Homebrew MySQL 8.0 downgrade to MySQL 5.7

downgrade homebrew installed mysql 8.0 to mysql 5.7 or before.

For now, the homebrew install mysql version 8.0 or later by default, for some reason, I need to use mysql 5.7, but I got some problem, here is a solution.

In my case, firstly I install mysql 8.0, like this

$ brew install mysql // 8.0 is default.

And next I found this, so I unlink it and install 5.7

$ brew unlink mysql
$ brew install mysql@5.7

But I try anyway, restart or switch other command, the version still 8.0 and I got some error

$ ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
$ ERROR! The server quit without updating PID file (/usr/local/var/mysql/Yish-MacBook-Pro.local.pid).

//mysqld
2018-08-21T06:20:00.845978Z 0 [ERROR] Cant't start server : Bind on unix socket: NO such file or directory 2018-08-21T06:20:00.845978Z 0 [ERROR] Do you already have another mysqld server running on socket: /tmp/mysql.sock ?

so I figure out some problem, homebrew will take .sock.lock to fetch file, following below doing:

  1. uninstall mysql and mysql@5.7 by homebrew
  2. negative to /tmp remove mysql.sock and mysql.sock.lock
  3. reinstall mysql@5.7
  4. service start

Notice

Following the description add path to .zshrc or .bash_profile.

It’ should be working, cheers.πŸ˜‹