huqideMacBook-Pro:~ huqi$ /usr/bin/ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
##其实只用把上面安装的install换成uninstall就行了
huqideMacBook-Pro:~ huqi$ /usr/bin/ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
安装软件,如:brew install oclint
卸载软件,如:brew uninstall oclint
搜索软件,如:brew search oclint
更新软件,如:brew upgrade oclint
查看安装列表, 如:brew list
更新Homebrew,如:brew update
huqideMacBook-Pro:~ huqi$ brewinstall wget
##使用wget更新hosts
huqideMacBook-Pro:~ huqi$ wgethttps://raw.githubusercontent.com/racaljk/hosts/master/hosts -qO/tmp/hosts && sudosh-c'cat /tmp/hosts > /etc/hosts'
##Homebrew在我的当前版本系统中,不需要像网上说的那样,先执行brew update命令更新,因为Homerew会自动更新
huqideMacBook-Pro:~ huqi$ brewinstall mysql
##安装过程很简单,不必干预,自动下载完成后,创建了一个无密码的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 startmysql now and restartat login:
brew services startmysql
Or, ifyou don't want/need a background service you can just run:
mysql.server start
==> Summary
huqideMacBook-Pro:~ huqi$ mysql.server start
Starting MySQL
. SUCCESS!
huqideMacBook-Pro:~ huqi$ 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 setonly those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
#启动验证插件
Press y|Y forYes, any other key forNo: 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 setthe password forroot 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 forYes, any other key forNo) : y
... Failed! Error: Your password does not satisfy the current policy requirements
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y forYes, any other key forNo) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created forthem. This is intended only for
testing, and to makethe installation go a bit smoother.
You should remove them before moving into a production
environment.
#删除匿名帐号
Remove anonymous users? (Press y|Y forYes, any other key forNo) : 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 forYes, any other key forNo) : no
... skipping.
By default, MySQL comes with a database named 'test'that
anyone can access. This is also intended only fortesting,
and should be removed before moving into a production
environment.
#删除test库
Remove test database and access to it? (Press y|Y forYes, any other key forNo) : 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 forYes, any other key forNo) : y
Success.
All done!
huqideMacBook-Pro:~ huqi$ 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'forhelp. Type '\c'to clearthe current input statement.
#查看表
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4rows inset(0.00 sec)
##安装完毕!