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
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:
Update 2:
You will get this error when the user user_name does not have the right to access your MySQL database. To resolve the error, you must create a user with the following command: mysql> GRANT ALL ON *. * to user_name@localhost IDENTIFIED BY 'password';
By default, the MySQL directories are installed under /usr/local/ . Even better, add /usr/local/mysql/bin to your PATH environment variable. You can do this by modifying the appropriate startup file for your shell. For more information, see Invoking MySQL Programs.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With