Mac—苹果电脑Mac OS下载并安装本地Mysql服务步骤详解
关注微信公众号:CodingTechWork,一起学习进步。
引言
使用mac安装mysql服务端供自己本地调试使用。
下载Mysql安装包
-
官方下载链接https://www.mysql.com/downloads/
点击进入Mysql社区下载页面
-
选择Mysql社区服务端(
Mysql Community Server
)下载 -
选择
macOS
,并选择对应的版本,由于我的mac
是英特尔的,而非ARM
,所以选择了x86,64-bit
的DMG
压缩包下载。
-
直接点击下载,无需登录或注册
安装Mysql
安装mysql程序
- 双击mysql安装包
- 不断点击继续
期间,会遇到输入密码,输入8位即可。
配置环境变量
打开终端执行以下操作
- 加入mysql环境变量
执行vim ~/.bash_profile
,加入环境变量PATH=$PATH:/usr/local/mysql/bin
,保存并退出。 - 环境变量生效
执行source ~/.bash_profile
验证使用
- 在终端输入
mysql --version
显示对应的版本
mysql Ver 8.0.29 for macos12 on x86_64 (MySQL Community Server - GPL)
- 登录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
- 系统偏爱设置中
烧不死的鸟就是凤凰