matt
matt

Reputation: 44293

mysql on osx: access denied and can't connect to socket

I can't seem to figure out what I have to do in order to install/setup mysql correctly on my new mac.

1.) I installend mysql via homebrew

2.) I'm able to run mysql.server start

enter image description here

3.) If I try to run mysql -u root -p I get this

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I googled and looked through all kind of sources, but can't seem to figure out what to do.


Update:

enter image description here

Update 2:

enter image description here

Upvotes: 10

Views: 1065

Answers (3)

Rick James
Rick James

Reputation: 142278

"No" password and password = '' are different things.

For "no" password:

mysql -u root

For '':

mysql -u root -p

and then enter empty line when prompted

mysql -u root -p root

with a space between -p and root means: (1) prompt for password, then (2) USE root to establish the default database.

mysql -u root -proot

without a space says "my password is 'root'".

Upvotes: 2

Anatoly
Anatoly

Reputation: 15530

Let's stop mysqld:

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Clean re-installation procedure:

brew remove mysql
brew cleanup
brew doctor

Backup your database before do next step. Then clean data directory up (to avoid manual run extra step mysql_install_db later):

sudo rm -rf /usr/local/var/mysql

The latest step is to install it again from scratch:

brew update
brew install mysql

Then run mysqld and try to login to CLI:

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
mysql -u root

Upvotes: 6

CM.
CM.

Reputation: 1047

On the 3rd step run it without -p option, which stands for password requirement: Run the command like this mysql -u root. If you need to set a password there is another post about it here.

Upvotes: 3

Related Questions