Failure to install mysql on macOS Mojave

MySQL 8 makes big changes compared with previous version 5.7. Downgrading directly to the lower version 5.7 from 8.x won't work.

Solution:

  1. Uninstall all MySQLs you've installed.

  2. Since you're setting up a new machine, there's no existing database. Just clean up the broken database.

    # brew-installed mysql
    rm -rf /usr/local/var/mysql
    
    # db from the official installed
    # should be located at /usr/local/mysql (I'm not very sure)
    ls -ald /usr/local/*mysql*
    # then delete any folders listed by ls
    
  3. You'd better remove the conf file /usr/local/etc/my.cnf as well.

  4. Reinstall MySQL.