Mac—苹果电脑Mac OS下载并安装本地Mysql服务步骤详解

技术公众号:后端技术解忧铺
关注微信公众号:CodingTechWork,一起学习进步。

引言

  使用mac安装mysql服务端供自己本地调试使用。

下载Mysql安装包

  1. 官方下载链接https://www.mysql.com/downloads/
    点击进入Mysql社区下载页面
    进入Mysql社区下载页面

  2. 选择Mysql社区服务端(Mysql Community Server)下载选择Mysql社区服务端下载

  3. 选择macOS,并选择对应的版本,由于我的mac是英特尔的,而非ARM,所以选择了x86,64-bitDMG压缩包下载。
    选择macOS,并选择对应的版本

  4. 直接点击下载,无需登录或注册
    直接点击下载,无需登录注册

安装Mysql

安装mysql程序

  1. 双击mysql安装包
    双击安装包
  2. 不断点击继续
    点击继续
    期间,会遇到输入密码,输入8位即可。

配置环境变量

打开终端执行以下操作

  1. 加入mysql环境变量
    执行vim ~/.bash_profile,加入环境变量PATH=$PATH:/usr/local/mysql/bin,保存并退出。
  2. 环境变量生效
    执行source ~/.bash_profile

验证使用

  1. 在终端输入mysql --version显示对应的版本
mysql  Ver 8.0.29 for macos12 on x86_64 (MySQL Community Server - GPL)
  1. 登录mysql后台
    mysql -uroot -p,输入密码
[xxxx %] mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.29 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

关闭mysql

  1. 系统偏爱设置中
    页面点击mysql
    关闭mysql服务
posted @ 2022-05-15 19:14  Andya_net  阅读(102)  评论(0编辑  收藏  举报  来源