-1

I installed mysql on my mac (after never having it installed on this machine previously) using brew install mysql. After the installation, I received this:

To connect:
    mysql -uroot
........
Or, if you don't want/need launchctl, you can just run:
  mysql.server start

Great, it worked. So I ran

kroe761$ mysql.server start
Starting MySQL
 SUCCESS! 
kroe761$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Wait, what? I never gave mysql a password to begin with. I tried using the sudo password, which didn't work (as expected). I also tried using -p but then just hitting enter, with no password, but that did not work either. So, how do I access mysql?

Edit: I also tried this, which also did not work.

kroe761$ mysql.server start -skip-grant-tables
Starting MySQL
 SUCCESS! 
kroe761$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
kroe761
  • 3,296
  • 9
  • 52
  • 81
  • mysql's root account has NOTHING to do with your system's root account. if you need to reset the root pw, then there's plenty of docs on the web on how to do that. – Marc B Jul 08 '16 at 19:52
  • Yes, I assumed mysql's root password has nothing to do with my system's password. Which is why I never expected sudo to work, just trying to troubleshoot. – kroe761 Jul 08 '16 at 19:54
  • Disappointing that you made no mention of doing a [search here for the error message](http://stackoverflow.com/search?q=Access+denied+for+user+%27root%27%40%27localhost%27+%28using+password%3A+NO%29). You could at least show some effort to research the issue before posting. – Ken White Jul 09 '16 at 02:08
  • Possible duplicate of [MacOSX homebrew mysql root password](http://stackoverflow.com/questions/9695362/macosx-homebrew-mysql-root-password) – Ken White Jul 09 '16 at 02:09
  • Ken White - I googled for hours, and tried every solution I could find. Including the ones on the page that you linked (and I also linked in my solution below), and only 1 of them worked; but only after I used an edit of that solution. This is my first attempt at installing mysql, I forgot that everyone is a technical expert on SO. The judgment here is strong. – kroe761 Jul 09 '16 at 13:21

1 Answers1

-3

After further googling, I found this:

https://stackoverflow.com/a/9878433/1535349

Note: I used mysqld --initialize for the last step, per the last comment.

Community
  • 1
  • 1
kroe761
  • 3,296
  • 9
  • 52
  • 81