前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Mac安装Mysql记录

Mac安装Mysql记录

作者头像
胡齐
发布2019-10-28 18:01:50
1.9K0
发布2019-10-28 18:01:50
举报
文章被收录于专栏:运维猫运维猫

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

代码语言:javascript
复制
 huqideMacBook-Pro:~ huqi$ /usr/bin/ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

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

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

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

代码语言:javascript
复制
 安装软件,如:brew install oclint
 卸载软件,如:brew uninstall oclint
 搜索软件,如:brew search oclint
 更新软件,如:brew upgrade oclint
 查看安装列表, 如:brew list
 更新Homebrew,如:brew update

4、使用brew安装wget

代码语言:javascript
复制
 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包

代码语言:javascript
复制
 ##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、启动服务

代码语言:javascript
复制
 huqideMacBook-Pro:~ huqi$ mysql.server start
 Starting MySQL
 . SUCCESS! 

7、执行安全配置

代码语言:javascript
复制
 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测试库,重新加载权限表

代码语言:javascript
复制
 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、测试连接

代码语言:javascript
复制
 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)
 ##安装完毕!
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-10-24,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 运维猫 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、安装,打开终端,复制粘贴,大约1分钟左右,下载完成,过程中需要输入密码,其他无需任何操作
  • 2、卸载,有安装就要有卸载,打开终端,复制粘贴
  • 3、Homebrew 怎么使用?常用命令有哪些
  • 4、使用brew安装wget
  • 5、利用homebrew安装mysql包
  • 6、启动服务
  • 7、执行安全配置
  • 8、删除匿名帐号,放开远程连接,删除test测试库,重新加载权限表
  • 9、测试连接
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档