Couldn't connect to MySQL from Mac after a long while

Since I couldn't even remember when I last installed MySQL, there would be no way of knowing which password I set for root. So, I took the following step:

1) In Terminal, I uninstalled MySQL using brew and reinstalled it

brew uninstall mysql
brew install mysql

It'd auto-update everything including Formulae/casks

I checked with mysql --version command and it was all good, but when I inserted the command: mysql -u root -p, it asked me for a password (which I think I got correct). Still, afterward, it showed me the following error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Realizing MySQL server hasn't even started, I ran the following command:

sudo mysql.server start

Then I inserted the password I set for my desktop. It accepted that and now I get another error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

To that, I restarted my server with this:

mysql.server restart

Finally, I've come to the MySQL monitor.

Whew, what a drama for such a simple thing.

いいなと思ったら応援しよう!