Mac安装Mysql记录

1、安装,打开终端,复制粘贴,大约1分钟左右,下载完成,过程中需要输入密码,其他无需任何操作

 huqideMacBook-Pro:~ huqi$ /usr/bin/ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2、卸载,有安装就要有卸载,打开终端,复制粘贴

 ##其实只用把上面安装的install换成uninstall就行了
 huqideMacBook-Pro:~ huqi$ /usr/bin/ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

3、Homebrew 怎么使用?常用命令有哪些

 安装软件,如:brew install oclint
 卸载软件,如:brew uninstall oclint
 搜索软件,如:brew search oclint
 更新软件,如:brew upgrade oclint
 查看安装列表, 如:brew list
 更新Homebrew,如:brew update

4、使用brew安装wget

 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'

5、利用homebrew安装mysql包

 ##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

6、启动服务

 huqideMacBook-Pro:~ huqi$ mysql.server start
 Starting MySQL
 . SUCCESS! 

7、执行安全配置

 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: 

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

 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! 

9、测试连接

 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)
 ##安装完毕!

打印一则招聘信息:自己的朋友目前在找UI设计师这方面的岗位,工作地点上海,有公司需要的话可以联系我。

关于运维学习、分享、交流,笔者开通了微信公众号【运维猫】,感兴趣的朋友可以关注下,欢迎加入,建立属于我们自己的小圈子,一起学运维知识。

有需要技术交流的小伙伴可以加我微信,期待与大家共同成长,本人微信:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值