0

I run brew install mysql or brew install mariadb then mysql_install_db and mysql_secure_installation but since I don't know the mysql password I just keep getting Access denied for user 'root'@'localhost' errors. It says it created root@localhost user with no password but I have to be the root system user. It also said it created another user without a password but I can't connect with that user either.

I've tried both of these solutions and nothing works:

Along with a couple other tutorials but it always comes back to needing to know the current password and I get stuck. Has anyone else had any luck installing mysql or mariadb on macos with brew?

Edit: I uninstalled and reinstalled and even after deleting /usr/local/var/mysql, when I run mysql_install_db it says mysql.user already exists so it can't install. How do I remove all databases when uninstalling?

Edit 2: So I think I finally managed to change the password but I keep getting this error message while trying to do mysql_secure_installation: Enter current password for root (enter for none): /usr/local/bin/mysql_secure_installation: line 249: .my.cnf.29733: Permission denied /usr/local/bin/mysql_secure_installation: line 250: .my.cnf.29733: Permission denied /usr/local/bin/mysql_secure_installation: line 251: .my.cnf.29733: Permission denied /usr/local/bin/mysql_secure_installation: line 253: .my.cnf.29733: Permission denied /usr/local/bin/mysql_secure_installation: line 218: .mysql.29733: Permission denied /usr/local/bin/mysql_secure_installation: line 220: .mysql.29733: No such file or directory

Dillan Wilding
  • 713
  • 7
  • 21

1 Answers1

0

I finally got it to work and decided for posterity I should update my question. Uninstalling and reinstalling mysql or mariadb via brew doesn't remove data. So I found a list of possible mysql files and went through the list and removed mysql and mariadb files.

I followed this answer for the most part except I didn't do #4 or #5: brew install mysql on macOS

The result of the mysql_install_db was 2 new user accounts. Since I don't use root on my computer, I use the user account for my user which has no password so I do a mysql -u dillanjwilding and then do a mysql password reset for my user. Exit and mysql -u dillanjwilding -p type my password and works. I can even connect via Sequel Pro. So everything seems to be working as expected now, at least for now.

Dillan Wilding
  • 713
  • 7
  • 21