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_installation

Securing the MySQL server deployment.

Enter password for user root: 
Error: Access denied for user 'root'@'localhost' (using password: YES)
andydennis@192 ~ % mysql_secure_installation

Securing 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: 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: 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) : y

New 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 requirements

New 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

相关推荐

  1. 阿里云centos安装mysql修改初始密码

    2024-02-07 05:08:02       61 阅读
  2. Mac brew 安装软件

    2024-02-07 05:08:02       43 阅读
  3. MacOS 14.3 安装 brew

    2024-02-07 05:08:02       59 阅读
  4. mac上用brew安装node

    2024-02-07 05:08:02       33 阅读
  5. Ubuntu安装MySQL设置密码/修改密码/删除密码

    2024-02-07 05:08:02       57 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-07 05:08:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-07 05:08:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-07 05:08:02       82 阅读
  4. Python语言-面向对象

    2024-02-07 05:08:02       91 阅读

热门阅读

  1. web读取前端txt并解析

    2024-02-07 05:08:02       54 阅读
  2. 比值计算 - 荣耀机试真题题解 ( 第1题 100 分)

    2024-02-07 05:08:02       42 阅读
  3. 天翼云CentOS7多IPsk5服务器一键搭建脚本

    2024-02-07 05:08:02       52 阅读
  4. 【Iceberg学习一】什么是Iceberg?

    2024-02-07 05:08:02       44 阅读
  5. linux驱动开发之常见面试问题

    2024-02-07 05:08:02       50 阅读
  6. 选择良好的条件比较语句

    2024-02-07 05:08:02       49 阅读
  7. Redis简单总结

    2024-02-07 05:08:02       52 阅读
  8. leetcode633 平方数之和

    2024-02-07 05:08:02       53 阅读
  9. Vue3 中的各种ref

    2024-02-07 05:08:02       49 阅读
  10. 网络版本计算器

    2024-02-07 05:08:02       40 阅读
  11. 网络安全面试题收集

    2024-02-07 05:08:02       58 阅读
  12. UI自动化中元素无法定位问题解决方法

    2024-02-07 05:08:02       57 阅读
  13. 【从零开始学设计模式】第一章_设计模式简介

    2024-02-07 05:08:02       58 阅读