前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Macbook通过brew安装mysql8.0

Macbook通过brew安装mysql8.0

作者头像
鳄鱼儿
发布2024-07-01 08:09:09
650
发布2024-07-01 08:09:09
举报

前言

MySQL 8 是mysql的最新版本,它带来了许多改进和新特性,主要新增特性如下:

  1. 公用表表达式(CTE) : CTE 可以简化复杂的 JOIN 查询和子查询,并支持递归查询,提高 SQL 的可读性和执行性能。
  2. 默认字符集变更 : 默认字符集由 latin1 变为 utf8mb4,utf8 也默认指向 utf8mb4,支持更多的 Unicode 字符。
  3. 克隆插件 : 提供了从一个实例克隆出另一个实例的功能,有助于快速创建 MySQL 实例和搭建复制环境。
  4. 资源组 : 允许调控线程优先级和绑定 CPU 核,需要相应的权限和系统支持。
  5. 角色管理 : 角色可以看作是权限的集合,简化了权限管理。
  6. 参数修改持久化 : 支持在线修改全局参数并持久化到配置文件中。
  7. InnoDB 锁等待改进 : 新增 NOWAIT 和 SKIP LOCKED 语法,允许跳过锁等待。
  8. GROUP BY 排序行为变更 : 为了兼容 SQL 标准,不再隐式排序。
  9. 自适应参数 : 自动调整参数以适应服务器的硬件配置。
  10. 窗口函数 : 从 MySQL 8.0 开始,引入了窗口函数,提供了新的查询方式。
  11. 性能提升 : 官方表示 MySQL 8.0 的性能是 MySQL 5.7 的两倍,特别是在读/写工作负载、IO 密集型工作负载和高竞争工作负载方面。
  12. JSON 扩展 : 提供了更多的 JSON 功能,包括 JSON 表函数和聚合函数。
  13. GIS 地理支持 : 增强了对地理信息系统的支持。
  14. DDL 原子性和崩溃安全 : 改进了数据定义语言的可靠性。
  15. 性能架构改进 : 提升了性能架构的可观察性。
  16. 安全增强 : 包括 OpenSSL 改进、新的默认身份验证、SQL 角色等。
  17. 错误日志改进 : 错误日志系统进行了重大改进,提供了更多的灵活性和自定义选项。
  18. 可管理性增强 : 包括撤销表空间管理、全局变量持久化等。
  19. 远程管理 : 通过 SQL RESTART 命令等实现远程管理。

博主发现自己的mysql版本还停留在5.7,从mysql8导出的数据居然无法导入mysql5.7,于是将mysql版本升级到了8.0,如下是博主的安装记录,供各位同学参考

📝 主旨内容

brew安装

代码语言:javascript
复制
brew install mysql@8.0

安装成功会输出提示:

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

mysql@8.0 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have mysql@8.0 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/mysql@8.0/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql@8.0 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/mysql@8.0/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/mysql@8.0/include"

To start mysql@8.0 now and restart at login:
  brew services start mysql@8.0
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/mysql@8.0/bin/mysqld_safe --datadir\=/opt/homebrew/var/mysql

可按照提示信息完成mysql配置。

环境配置

查看brew安装mysql得路径

代码语言:javascript
复制
brew --prefix mysql

编辑环境变量,注意修改路径

代码语言:javascript
复制
# 编辑环境变量
sudo vi ~/.zshrc

# 增加以下内容
export PATH="/opt/homebrew/opt/mysql@8.0/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/mysql@8.0/lib"
export CPPFLAGS="-I/opt/homebrew/opt/mysql@8.0/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql@8.0/lib/pkgconfig"

# 加载配置
source ~/.zshrc

启动服务

代码语言:javascript
复制
brew services start mysql@8.0

安全配置

代码语言:javascript
复制
mysql_secure_installation

配置过程信息

代码语言:javascript
复制
root@MacBook-Pro ~ % 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
Please set the password for root here.
# 输入密码
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) : n

 ... 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) : y
Success.

All done! 
root@MacBook-Pro ~ % 

连接mysql

代码语言:javascript
复制
mysql -u root -p
# 输入密码
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-07-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

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

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

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • 📝 主旨内容
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档