1、brew install mysql 2、brew services start mysql 3、mysql_secure_installation cometdeMacBook-Pro:~ co
1、brew install mysql
2、brew services start mysql
3、mysql_secure_installation
cometdeMacBook-Pro:~ comet$ mysql_secure_installationSecuring the MySQL server deployment.Connecting to MySQL using a blank password.VALIDATE PASSWORD PLUGIN can be used to test passwordsand improve security. It checks the strength of passwordand allows the users to set only those passwords which aresecure enough. Would you like to setup VALIDATE PASSWORD plugin?Press y|Y for Yes, any other key for No: N // 这个选yes的话密码长度就必须要设置为8位以上,但我只想要6位的Please set the password for root here.New password: // 设置密码Re-enter new password: // 再一次确认密码By default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y // 移除不用密码的那个账户Success.Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n ... skipping.By default, MySQL comes with a database named 'test' thatanyone can access. This is also intended only for testing,and should be removed before moving into a productionenvironment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database...Success. - Removing privileges on test database...Success.Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : ySuccess.All done!
设置远程访问:
1、mysql -u root -p
2、grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
3、打开 /usr/local/Cellar/mysql/5.7.16/下的homebrew.mxcl.mysql.plist文件,去掉
<string>--bind-address=127.0.0.1</string>
4、brew services stop mysql
brew services start mysql