I am trying to set up MySQL on Mac OS 10.6 using Homebrew through brew install mysql 5.1.52.
All went well, and MySQL install dB was also successful.
However, when I try to connect to the server using the following methods:
/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 also try mysqladmin or mysql using -u root -proot to access mysqladmin or mysql using -u root -proot,
But it can't be used with or without a password.
This is a new installation on a new computer. As far as I know, you must use the root password to access the new installation. I also tried:
/usr/local/Cellar/mysql/5.1.52/bin/mysql_secure_installation
But I got it, too
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
#1 building
Brewing information mysql
mysql: stable 5.6.12 (bottled) http://dev.mysql.com/doc/refman/5.6/en/ Conflicts with: mariadb, mysql-cluster, percona-server /usr/local/Cellar/mysql/5.6.12 (9363 files, 353M) * Poured from bottle From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/mysql.rb ==> Dependencies Build: cmake ==> Options --enable-debug Build with debug support --enable-local-infile Build with local infile loading support --enable-memcached Enable innodb-memcached support --universal Build a universal binary --with-archive-storage-engine Compile with the ARCHIVE storage engine enabled --with-blackhole-storage-engine Compile with the BLACKHOLE storage engine enabled --with-embedded Build the embedded server --with-libedit Compile with editline wrapper instead of readline --with-tests Build with unit tests ==> Caveats A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly. To connect: mysql -uroot To reload mysql after an upgrade: launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Start mysql.service
. ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid).
Or mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I'm looking for a solution for a while, but I can't solve my problem. I tried several solutions on stackoverflow.com, but it didn't help.
#2 building
I ran into the same problem after trying to restart mysql.
For convenience, I use the following two aliases in. profile
alias mysql-stop='launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist' alias mysql-start='launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist'
After stopping mysql and trying to restart, I ran into a problem you had. I investigated the launchctl load, which reported a load not found 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 the mysql start alias as follows
alias mysql-start='launchctl load -w -F ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist'
This solves my problem and may be useful to you.
#3 building
This is a detailed description, which combines the method of removing all MySQL from Mac, and then installing The Brew Way as described above by Sedorner:
According to the technical laboratory Delete MySQL completely
- ps -ax | grep mysql
- Stop and kill any MySQL process
- sudo rm /usr/local/mysql
- sudo rm -rf /usr/local/var/mysql
- sudo rm -rf /usr/local/mysql*
- sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
- sudo rm -rf /Library/StartupItems/MySQLCOM
- sudo rm -rf /Library/PreferencePanes/My*
- launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
- Edit / etc/hostconfig and delete the line MYSQLCOM=-YES-
- rm -rf ~/Library/PreferencePanes/My*
- sudo rm -rf /Library/Receipts/mysql*
- sudo rm -rf /Library/Receipts/MySQL*
- sudo rm -rf /private/var/db/receipts/*mysql*
- sudo rm -rf /tmp/mysql*
- Try to run mysql, it doesn't work
from then on StackOverflow In the reply, Brew MySQL is installed by user Sedorner
- brew doctor and correct any errors
- brew remove mysql
- brew cleanup
- brew update
- brew install mysql
- unset TMPDIR
- mysql_install_db --verbose --user= whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
- mysql.server start
- Run Brew's recommended command to add MySQL to launchctl so that it starts automatically at startup
mysql should now work and be running all the time
God's speed.
#4 building
The "basic path" of Mysql is stored in / etc/my.cnf and will not be updated when you upgrade brew. Just open it and change the basedir value
For example, change this:
[mysqld] basedir=/Users/3st/homebrew/Cellar/mysql/5.6.13
Point to new version:
[mysqld] basedir=/Users/3st/homebrew/Cellar/mysql/5.6.19
Restart mysql with the following command:
mysql.server start
#5 building
When using brew with the latest versions of mysql and yosemite, none of the above answers (or any of the dozens I've seen elsewhere) worked for me. I finally installed a different version of mysql through brew.
Specify the old version by saying (for example)
brew install mysql56
Work for me. I hope it helps someone. It's a frustrating problem, and I feel like I'll never stop.