0

I installed via brew on macos the package mysql@5.7 so that can work with Laravel, following the present documentation but I cannot access to mysql@5.7

$ mysql -u root -p 
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

the documentation says

Database

If you need a database, try MySQL by running brew install mysql@5.7 on your command line. Once MySQL has been installed, you may start it using the brew services start mysql@5.7 command. You can then connect to the database at 127.0.0.1 using the root username and an empty string for the password.

I made a long research and found that is a really common problem but whatever thing I tried did not work

I launched mysqld skipping flushing privileges but then cannot root as well with mysql -u root -p I tried to run a php artisan cache:clear I tried to use sudo -s to log as root and other things that at the moment do not remember anymore(basically is 3 days I am busy) I am really surprised that a framework as Laravel that should be easy, has this kind of problems that are not reported by the documentation tutorial nor laracast, I did not do nothing strange, just followed the guide

John smith
  • 57
  • 6
  • [Do any of these answers solve your problem?](https://stackoverflow.com/questions/21944936/error-1045-28000-access-denied-for-user-rootlocalhost-using-password-y) – FullStackOfPancakes Oct 25 '20 at 19:27
  • Yes was one of the first post I went trough, furthermore the link you are giving me refers to Linux while I am on MacOS, even if conceptually the operations are the same but have to be done with other command and directories. ex, start service via `brew services start mysql@5.7` instead of `systemctl` and so on. Also a fresh installation is not helping me, I am afraid if is not a common bug I have some mysql cache file am not able to cancel – John smith Oct 25 '20 at 19:51
  • John, this might seem crazy, but have you tried just omitting the `-p`? So your command is `mysql -u root` on a fresh install? – FullStackOfPancakes Oct 25 '20 at 19:58
  • I am in the middle of something, there is an important break in 5.7 give me 5 min please – John smith Oct 25 '20 at 20:07
  • 1
    @FullStackOfPancakes I did it. I combined three different google searches. I am going to write the procedure I followed as response to try to help somebody else in the future, thank you for your interest – John smith Oct 25 '20 at 20:12
  • 1
    Awesome! Glad you were able to work it out - look forward to seeing how you did it – FullStackOfPancakes Oct 25 '20 at 20:14
  • please have a look now @FullStackOfPancakes if you think I should edit something to help others please do not hesitate to ask – John smith Oct 25 '20 at 20:21

1 Answers1

0

I saw a post where for this error was suggested to change password, but also in this case I went through some issue, so I had to combine different responses but now works I followed mainly this post but arrived to the point 5:

5 : modify your password your new password should be input in "()"

I had to deal with a change in mysql@5.7 namely if you do show tables you see that there is not a password column anymore, so you get an error message that does not exist the column password, so I just passed

update user set authentication_string=password('1111') where user='root';// please notice 1111 is the password you fill

as indicated in this other post

then I followed the other step indicated by the post, to flush privileges and quit finally I started again the daemon with $brew services start mysql@5.7 and $mysql -u root -p (herethepassword) did not work so I did

$mysql --password=(herethepassword) --user=root

and worked

John smith
  • 57
  • 6