Reputation: 96454
How can I get mysql installed and able to use it?
I've tried:
$ brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.9.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/mysql-5.7.9.yosemite.bottle.tar.gz
==> Pouring mysql-5.7.9.yosemite.bottle.tar.gz
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
To connect:
mysql -uroot
To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
==> Summary
🍺 /usr/local/Cellar/mysql/5.7.9: 12629 files, 464M
$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
$ mysql.server start
Starting MySQL
SUCCESS!
$ mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
$
Upvotes: 2
Views: 4081
Reputation: 784
Try to use this commande:
sudo mysql -u root -p
then Enter password:*******
Upvotes: 0
Reputation: 6512
For me turns out i already had mysql somewhere on my computer so a password was set there or something. After spending hours trying every solution out there this is what worked for me:
$ brew services stop mysql
$ pkill mysqld
$ rm -rf /usr/local/var/mysql/ # NOTE: this will delete your existing database!!!
$ brew postinstall mysql
$ brew services restart mysql
$ mysql -uroot
all credit to @Ghrua
Upvotes: 5
Reputation: 206
Using mysqld --initialize
worked for me. I just had to cut-n-paste the password from the below output.
[Note] A temporary password is generated for root@localhost: ?(A+3F48ed.Y
Upvotes: 0
Reputation: 21
I just had the same problem, this is how i solved it (but only try this if you have no data in your db!!):
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm -rf /usr/local/var/mysql
mysqld --initialize
The initialize method will create the data dir, and also an root user with a temporary password, be sure you copy this password, and than login and change the password.
Upvotes: 2
Reputation: 2045
Try in CLI :
mysql -uroot -p
You need to specify that this user has a password.
Upvotes: 0