mysql 5.7以后增加了密码安全认证,建议你直接brew install mysql 安装,或者安装之前brew info mysql 查看一下安装信息.
1,用brew安装好mysql以后是没有初始密码的,你需要先通过mysql.server start 启动mysql 。
$ mysql.server start
Starting MySQL
SUCCESS!
2.启动成功后,你可以通过 $mysql_secure_installation 来设置初始密码,如下:
$ mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: y //是否安装密码安全插件?选择y
There are three levels of password validation policy: //有以下几种密码强度选择
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 //这里果断选择0,只要8位数字就可以了,选1的话密码强度更高,要有大写,小写,特殊字符等,烦人!
接下来的设置就很简单了,英文不认识的话可以翻译。。。
3. 如果已设置了root密码,需要修改的话,也要根据所选的密码强度来修改,我的办法是直接卸载密码强度插件后重新设置新密码的,卸载插件需要先用root登陆mysql 如下:
mysql> UNINSTALL PLUGIN validate_password ;
Query OK, 0 rows affected (0.00 sec)
然后继续第2步就可以了。
不懂的继续问吧,也可以参考CentOS6.5安装MySQL5.7.9centos 哈哈,最近我也在折腾osx 10.11上的mysql ,用c语言写程序连接mysql编译的时候总是出现库问题。。。烦死了。。。