I'm trying to setup up MySQL on mac os 10.6 using Homebrew by brew install mysql 5.1.52
.
Everything goes well and I am also successful with the mysql_install_db
.
However when I try to connect to the server using:
/usr/local/Cellar/mysql/5.1.52/bin/mysqladmin -u root password 'mypass'
I get:
/usr/local/Cellar/mysql/5.1.52/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
I've tried to access mysqladmin or mysql using -u root -proot
as well,
but it doesn't work with or without password.
This is a brand new installation on a brand new machine and as far as I know the new installation must be accessible without a root password. I also tried:
/usr/local/Cellar/mysql/5.1.52/bin/mysql_secure_installation
but I also get
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
If mysql is already installed
Stop mysql completely.
mysql.server stop
<-- may need editing based on your versionps -ef | grep mysql
<-- lists processes with mysql in their namekill [PID]
<-- kill the processes by PIDRemove files. Instructions above are good. I'll add:
sudo find /. -name "*mysql*"
rm -rf
these files. Note that many programs have drivers for mysql which you do not want to remove. For example, don't delete stuff in a PHP install's directory. Do remove stuff in its own mysql directory.Install
Hopefully you have homebrew. If not, download it.
I like to run brew as root, but I don't think you have to. Edit 2018: you can't run brew as root anymore
sudo brew update
sudo brew install cmake
<-- dependency for mysql, usefulsudo brew install openssl
<-- dependency for mysql, usefulsudo brew info mysql
<-- skim through this... it gives you some idea of what's coming nextsudo brew install mysql --with-embedded; say done
<-- Installs mysql with the embedded server. Tells you when it finishes (my install took 10 minutes)Afterwards
sudo chown -R mysql /usr/local/var/mysql/
<-- mysql wouldn't work for me until I ran this commandsudo mysql.server start
<-- once again, the exact syntax may varyI had the same issue after I tried to restart mysql.
I use the following two aliases in my .profile for convenience
After stoping mysql and then trying to restart I experienced the issue you were having. I looked into the launchctl load and it was reporting a “nothing found to load” error.
After a quick search I found this..
http://www.daveoncode.com/2013/02/01/solve-mac-osx-launchctl-nothing-found-to-load-error/
So I updated me
mysql-start
alias as followsThis solved my issue which may be useful for you.