Mac OS 10.13 Mysql安装记录

1.安装Homebrew

官方解释:Homebrew是以最简单,最灵活的方式来安装苹果公司在MacOS中不包含的UNIX工具。

具体安装方式已经烂大街了,不再赘述,自行安装。

2.利用homebrew安装mysql包

Homebrew在我的当前版本系统中,不需要像网上说的那样,先执行brew update命令更新,因为Homerew会自动更新

XXXdeMacBook-Pro:Dev XXX$ brew install mysql

Updating Homebrew...
==> Auto-updated Homebrew!

安装过程很简单,不必干预,自动下载完成后,创建了一个无密码的root帐号

==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.21.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mysql-5.7.21.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/mysql/5.7.21/bin/mysqld --initialize-insecure --user=xxx --basedir=/usr/local/Cellar/mysql/5.7.21 --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary

启动服务

XXXdeMacBook-Pro:Dev xxx$ mysql.server start
Starting MySQL
. SUCCESS! 

执行安全配置

XXXdeMacBook-Pro:Dev xxx$ mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

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

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: 1
Please set the password for root here.

New password: 

Re-enter new password: 
#此处忽略密码评定,未达到100就确认了,所以要求重新设置
Estimated strength of the password: 25 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
 ... Failed! Error: Your password does not satisfy the current policy requirements

New password: 

Re-enter new password: 

删除匿名帐号,放开远程连接,删除test测试库,重新加载权限表

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
#删除匿名帐号
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 at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : no

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

#删除test库
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 changes
made so far will take effect immediately.
#重新加载权限表
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 
测试连接
XXXdeMacBook-Pro:Dev xxx$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.21 Homebrew

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
#查看表
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
安装完毕!

你可能感兴趣的:(Mac OS 10.13 Mysql安装记录)