1、安装mysql

#brew install mysql

报错

Error: The following directories are not writable by your user:
/usr/local/lib You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/lib

意思是 您应该将这些目录的所有权更改为您的用户

执行以下命令设置权限

#sudo chown -R wuj /usr/local/lib

然后重新安装即可 brew install mysql

2、启动mysql服务

#mysql.server start

3、设置密码

通过brew安装后默认密码为空

执行以下命令设置密码

#mysql_secure_installation
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT 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 component? 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、1、2选择一个

因为手误我选择了1,但在后面设置密码时无法设置简单密码

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

解决

更改密码强度为 LOW

先登录mysql

#mysql -uroot

设置validate_password_policy为0(表示等级low)

set global validate_password_policy=0;

执行会报错

ERROR 1193 (HY000): Unknown system variable 'validate_password_policy'

原因是 MySQL 5.7和MySQL 8.0版本变量名不同

validate_password_policy是在版本 MySQL 5.7中 存在 ,而 MySQL 8.0不存在

解决,执行以下命令查看密码验证插件

SHOW VARIABLES LIKE 'validate_password%';
Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1

可以看到在mysql8.0中 变量名 为 validate_password.policy

好了,修改变量名后执行设置成功

set global validate_password.policy=0;

除此之外 ,还需设置密码长度(默认是长度8位以上)

set global validate_password.length=4;

解决以上问题后再次执行以下命令,设置密码即可

#mysql_secure_installation

4、mysql登录验证

#mysql -uroot -p

显示数据库

#show databases;

另:

在php连接数据库时报错,无法连接到数据库

The server requested authentication method unknown to the client

发现是因为mysql8.0版本的问题

打开mysql数据库 -》用户-》编辑root用户修改

修改插件 caching_sha2_password为 mysql_native_password即可

参考

https://blog.csdn.net/maxsky/article/details/51171474

https://blog.csdn.net/HaHa_Sir/article/details/80552663

mac使用brew安装mysql的更多相关文章

  1. Mac用brew安装MySQL

    1.先安装brew 网址:https://brew.sh/ 复制命令:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent ...

  2. mac使用brew安装mysql报RROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    使用mac安装mysql安装完后运行 mysql -uroot -p 报了 ERROR 2002 (HY000): Can't connect to local MySQL server throug ...

  3. 【MySQL】Mac通过brew安装的MySQL重启方法

    问题 在 Mac 上通过 brew install mysql 安装的的MySQL使用基本MySQL命令重启会失败: mysql.server stop mysql.server start mysq ...

  4. Mac下brew安装与配置mysql

    一.打开mac控制台 $ brew install mysql 二.启动mysql服务 $ mysql.server start 三.初始化mysql配置 1 rainMacBook-Pro:~ co ...

  5. Mac通过homebrew 安装mysql

    来源:http://timtang.me/blog/2011/12/07/mac-homebrew-mysql/ 使用MBP有一年了,开始想在工作中使用mac由于各种不习惯最终失败,导致自己使用了一年 ...

  6. Mac OS下面安装mysql以及mysql常用命令

    使用brew安装mysql brew install mysql 安装成功后使用下面命令启动/关闭服务 brew services start mysql brew services stop mys ...

  7. mac brew安装mysql

    mac不自带mysql,这里需要重新安装,方法依然很简单 brew install mysql unset TMPDIR mysql_install_db --verbose --user=`whoa ...

  8. Mac中使用brew安装mysql

    若不考虑版本直接执行以下命令 brew install mysql 若要选择版本只要加上@版本即可,例如 brew install mysql@5.7 安装完后启动mysql mysql.server ...

  9. mac环境下安装mysql

    一,下载mysql 官网"Community " 下会看到"MySQL Community Server"下方有一个"download"点击 ...

随机推荐

  1. 17. pt-online-schema-change

    在平时MySQL的运维过程中,经常会遇到表结构的变更.在表比较小的时候,直接进行变更,时间较短,但是当表非常大的时候,这么做会导致应用卡死,服务不可用.目前InnoDB引擎是通过以下步骤来进行DDL的 ...

  2. C++ 提取网页内容系列之二

    标 题: C++ 提取网页内容系列作 者: itdef链 接: http://www.cnblogs.com/itdef/p/4171203.html 欢迎转帖 请保持文本完整并注明出处 另外一种下载 ...

  3. Spring Boot学习笔记:整合H2数据库

    H2数据库:java语言编写的嵌入式sql数据库.可以和应用一起打包发布. H2有三种连接模式(Connection Modes): Embedded mode (local connections ...

  4. sas通过IMPORT过程读取外部文件数据

    SAS通过IMPORT过程读取外部文件数据 使用IMPORT过程导入带分隔符的文件外,Microsoft Access数据库文件.Miscrosft Excel工作簿. dBase文件.JMP文件.S ...

  5. python模块:hmac

    """HMAC (Keyed-Hashing for Message Authentication) Python module. Implements the HMAC ...

  6. IntelliJ IDEA 2017版 spring-boot2.0.2 搭建 JPA springboot DataSource JPA sort排序方法使用方式, 添加关联表的 order by

    1.sort可以直接添加在命名格式的字段中 List<BomMain> findAllByDeleted(Integer deleted, Sort sort); 2.可以作为pageab ...

  7. python基本数据类型之列表和元组

    python基本数据类型之列表与元组 python中list与tuple都是可以遍历类型.不同的是,list是可以修改的,而元组属于不可变类型,不能修改. 列表和元组中的元素可以是任意类型,并且同一个 ...

  8. iOS逆向之class-dump

    1.class-dump class-dump是用来dump目标文件的类信息的工具.它利用Objective-C语言的runtime的特性,将存储在mach-O文件中的@interface和@prot ...

  9. Java SE核心之一:常用类,包装类,其他基本数据类型包装类。

    在Java继承体系中,java.lang.Object类位于顶端(是所有对象的直接或间接父类).如果一个类没有写extends关键字声明其父类,则该类默认继承java.lang.Object类.Obj ...

  10. koa-static与react-create-app搭配的路径

    概述 前端路由与后端路由的结合一直是一个难题.koa-static这个中间件能够把静态资源"搬到"后端路由上面去,react-create-app在不解构的情况下只会把资源打包到b ...