2016-12-26 回答
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的话密码强度更高,要有大写,小写,特殊字符等,烦人!
接下来的设置就很简单了,英文不认识的话可以翻译。。