使用brew安裝mysql
w3@mac:~ > brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.9.el_capitan.bottle.tar.gz
curl: (35) Server aborted the SSL handshake
Error: Failed to download resource "mysql"
Download failed: https://homebrew.bintray.com/bottles/mysql-5.7.9.el_capitan.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Downloading https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.9.tar.gz
Already downloaded: /Library/Caches/Homebrew/mysql-5.7.9.tar.gz
==> cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/mysql/5.7.9 -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DMYSQL_DATADIR=/usr/local/var/mysql -DINSTALL_INCLUDEDIR=include/mysql -DINSTALL_M
==> make
==> make install
==> /usr/local/Cellar/mysql/5.7.9/bin/mysqld --initialize --user=w3 --basedir=/usr/local/Cellar/mysql/5.7.9 --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> 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, built in 6.4 minutes
但是使用mysql.server start 啟動后使用mysql -uroot提示訪問被阻止
解決方案:
mysql.server stop
rm -r /usr/local/var/mysql
mysqld --initialize —user=`whoami` --basedir=/usr/local/Cellar/mysql/5.7.9 --datadir=/usr/local/var/mysql --tmpdir=/tmp
輸出的最后一行:
[Note] A temporary password is generated for root@localhost: h;7/yqnxrMaR
冒號后面的就是密碼
我們自己的本機不需要這么復(fù)雜的密碼, 改成簡單的密碼
mysqladmin -uroot -p password ‘123456'
輸入舊的密碼后就可以把密碼改成123456了
- ps: 安裝的密碼看看是否則 ~/.mysql_secret