0

I installed MySQL on MacOS El Capitan. But I am not able to access it.

I get the error:

ERROR 1045 (28000): Access denied for user 'denismilosavljevic'@'localhost' (using password: NO)

How do I properly connect?

shilovk
  • 11,718
  • 17
  • 75
  • 74
Denis Milosavljevic
  • 365
  • 4
  • 8
  • 17
  • 2
    Possible duplicate of [Stuck with Access Denied for user 'root'@'localhost' - Terminal, Mac](http://stackoverflow.com/questions/25896082/stuck-with-access-denied-for-user-rootlocalhost-terminal-mac) – Hristo Eftimov Jan 04 '17 at 07:36

1 Answers1

0

On OS X to start/stop/restart MySQL pre 5.7 from the command line:

 sudo /usr/local/mysql/support-files/mysql.server start
 sudo /usr/local/mysql/support-files/mysql.server stop
 sudo /usr/local/mysql/support-files/mysql.server restart

If it is running then try mysql -u root -p

Update :

If still not working then set your path

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

& try again

mysql -u root -p

Shivkumar kondi
  • 6,458
  • 9
  • 31
  • 58
  • I did, then I get this error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2) – Denis Milosavljevic Jan 04 '17 at 07:43
  • By default, the root user in MySQL doesn't have a password and can only connect from localhost. So /usr/local/mysql/bin/mysql -uroot should work and Please check your mysql path – Shivkumar kondi Jan 04 '17 at 07:53
  • Unfortunately no, I get error: Access denied for user 'root'@'localhost' (using password: NO) – Denis Milosavljevic Jan 04 '17 at 08:46
  • So, the problem came up after I installed mysql and close the pop up window which comes after installation where is written mysql password. Then I tried to reset password what did not worked. I installed mysql again, but it doesn´t seem to override existing files.. – Denis Milosavljevic Jan 04 '17 at 08:48
  • Opps... It may take a half hour more for you. But try to Remove all files related to mysql completely and reinstall it properly. On prompt of password use simple password. – Shivkumar kondi Jan 04 '17 at 08:51