使用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
冒号后面的就是密码
我们自己的本机不需要这么复杂的密码, 改成简单的密码
mysqladmin -uroot -p password ‘123456'
输入旧的密码后就可以把密码改成123456了
- ps: 安装的密码看看是否则 ~/.mysql_secret
网友评论