0

I downloaded MySQL 5.7.17 for Mac and installed it. I can start and stop the SQL server from my Preferences > MySQL. It is shown as an instance on port 3306 from Workbench so all that seems fine. However, during install toward the end a pop-up window listed a password I was supposed to use. I assumed it would be promptly needed so copied on the clipboard. Few mins later having not been prompted for it yet, I copied something else in the clipboard thus losing it.

I have been trying to get some sort of client of mysql command line so I can enter sql commands, however there is no "Application" installed to use to access the server. I have scoured the MySQL documentation and Stack and beyond, and searched for how to get the password reset, and a mysql client/command line, but all the articles seem to assume you already have access to a "MySQL terminal"/"command line". I only have access to my normal Mac Terminal, and most commands in the normal Terminal window either fail or require the password I don't have, for example:

$ mysqld --skip-grant-tables

-bash: mysqld: command not found

$ mysql -u root -p

-bash: mysql: command not found

$ sudo sh -c 'echo /usr/local/mysql/bin > /etc/paths.d/mysql'

Password: (this is probably the password I was given that got overwritten? When I try the admin password of the machine it sends me back to the prompt)

$ sudo mysqld_safe --skip-grant-tables  (after I'd stopped the server)

sudo: mysqld_safe: command not found

Can somebody please help me figure out how to get to a "MySql Terminal" and if I need this password that got overwritten, how to reset it? (it seems like uninstalling MySQL to repeat the steps and this time take better care of the password is actually horrendously difficult / no uninstall protocol?).

Thank you so very much.

--- Update: I used the How To Uninstall suggested by Josh M and then re-installed. This time I saved the password (so far, not sure how / where I need to use it). However, I must really be missing something b/c I still can't get access to mysql.

/usr/local/mysql/bin/mysql

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

Then I did $ export PATH=$PATH:/usr/local/mysql/bin but I still get ERROR 1045.

2 Answers2

1

Try these set of commands

$ sudo /usr/local/mysql/support-files/mysql.server stop
$ sudo /usr/local/mysql/support-files/mysql.server start --skip-grant-tables
/usr/local/mysql/bin/mysql
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'YOUR_NEW_PASSWORD';
EXIT;
$ sudo /usr/local/mysql/support-files/mysql.server stop
$ sudo /usr/local/mysql/support-files/mysql.server start
$ mysql -u root -p
$ Enter Password:  ENTER_YOUR_NEW_PASSWORD_HERE 

And enjoy

Daksharaj kamal
  • 526
  • 1
  • 4
  • 11
0

There's a tutorial for resetting passwords here: https://www.howtoforge.com/setting-changing-resetting-mysql-root-passwords

Your MySQL command line interface (cli) is probably at:

/usr/local/mysql/bin/mysql

Honestly it might be better to reinstall. There's an SO on that: How do you uninstall MySQL from Mac OS X?

Community
  • 1
  • 1
Josh Miller
  • 440
  • 3
  • 11
  • command doesn't work --------- $ /usr/local/mysql/bin/mysql ERROR 1045 (28000): Access denied for user 'Robert'@'localhost' (using password: NO) – Robert Ribciuc Jan 08 '17 at 16:58
  • You must have required a password when you did the MySQL setup then. Really I'd just delete it all and start over again. You're not far enough along to have created any meaningful data or content. Finding out how to uninstall/reinstall will be a good learning experience. – Josh Miller Jan 08 '17 at 18:13