当前位置: 首页 > news >正文

Mac利用brew安装mysql并设置初始密码

前言

之前一直是在windows上开发后段程序,所以只在windows上装mysql。(我记得linux只需要适应yum之类的命令即可)

另外, linux的移步 linux安装mysql (详细步骤,初次初始化,sql小例子,可视化操作客户端推荐)

好家伙,我佛了,写完当天网上发现自己之前写过一篇 brew 安装mysql (Mac OS), 不过那篇没有说如何设置初始密码.


安装mysql

brew install mysql

等它装完就好啦

开启mysql

mysql.server start

顺带一提,关闭命令是

mysql.server stop

设置初始密码

mysql_secure_installation

输入上面这个命令,就会提示你一系列操作,就可以设置我们的初始密码了

andydennis@192 ~ % mysql_secure_installationSecuring the MySQL server deployment.Enter password for user root: 
Error: Access denied for user 'root'@'localhost' (using password: YES)
andydennis@192 ~ % mysql_secure_installationSecuring the MySQL server deployment.Enter password for user root: 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: yThere 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                  filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Using existing password for root.Estimated strength of the password: 25 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : yNew password: Re-enter new password: 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 requirementsNew password: Re-enter new password: Estimated strength of the password: 50 
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) : n... 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.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : ... skipping.
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) : ... skipping.
All done! 

这里密码需要大于等于8个,所以我设置了 root1234

然后就可以用我们熟悉的命令登录上mysql了

mysql -u root -p

输入密码 root1234


查看 有无启动

ps aux|grep mysqld

或者

ps -ef|grep mysqld

或者换一种思路,看3306端口号是否被占用

lsof -i :3306
http://www.lryc.cn/news/295343.html

相关文章:

  • R语言入门笔记2.2
  • 一般系统的请求认证授权思路【gateway网关+jwt+redis+请求头httpheader】
  • c# 正则表达式 帮助类
  • 告别mPDF迎来TCPDF和中文打印遇到的问题
  • mysql 多数据源
  • uniapp 使用renderjs引入echarts
  • hr最讨厌这6种应届生简历❌
  • 【Linux笔记】文件系统与软硬链接
  • vue3(笔记)
  • Java面向对象 this
  • 阿里云游戏服务器租用价格表,2024最新报价
  • 2-1 动手学深度学习v2-Softmax回归-笔记
  • laravel distinct查询问题,laravel子查询写法
  • AI助力农作物自动采摘,基于DETR(DEtection TRansformer)开发构建作物生产场景下番茄采摘检测计数分析系统
  • C语言——字符串大小写互换
  • macOS的设置与常用软件(含IntelliJ IDEA 2023.3.2 Ultimate安装,SIP的关闭与开启)
  • http伪造本地用户字段系列总结
  • Hadoop-IDEA开发平台搭建
  • block任务块、rescue和always、loop循环、role角色概述、role角色应用、ansible-vault、sudo提权、特殊的主机清单变量
  • Qt:QFileDialog
  • 我的QQ编程学习群
  • 【C++】类与对象(四)——初始化列表|explicit关键字|static成员|友元|匿名对象
  • ChatGPT高效提问—prompt常见用法
  • 使用vite创建vue+ts项目,整合常用插件(scss、vue-router、pinia、axios等)和配置
  • 泛型、Trait 和生命周期(上)
  • <网络安全>《18 数据安全交换系统》
  • Kafka 生产调优
  • springboot162基于SpringBoot的体育馆管理系统的设计与实现
  • Interpolator:在Android中方便使用一些常见的CubicBezier贝塞尔曲线动画效果
  • Nacos安装,服务注册,负载均衡配置,权重配置以及环境隔离