Failure to install thesql on macOS Mojave

homebrewmojaveMySQL

I've moved to a new machine and installing MySQL is turning out to be quite an issue (the last time I installed it on a mac it was quite seamless).

I used two approaches to install MySQL: brew and the offical installer

Brew:

I started with brew install mysql. This installed the latest version of MySQL. It initially worked and I could log into the root user without a password. When I tried to set the password for the root account I ended up being locked out of the root account. I proceeded to uninstall that version of MySQL and tried a different version (5.7). When I installed that I got the following error: ERROR 2061 (HY000): Authentication plugin 'sha256_password' reported error: Authentication requires SSL encryption. I ended up uninstalling that version of MySQL as well.

Native Package:

Tried the latest version was asked for a password but could not login to the root user with the password. Received this error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'. Additionally I could not run mysql.server start, received the following error: command not found: mysql.server. I did not add anything to my PATH, should I have done that?

Additionally, this is how the MySQL widget in the System Information looks like. I tried pressing Start MySQL Server a bunch of times, it would start and almost immediately stop.

Can anyone suggest a clean way in which I can remove all these defunct installations and have a clean MySQL install?

MySQL server not starting

Best Answer

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.