MySQL安装

Mac OS 安装 MySQL

Posted by Tan Lin on March 16, 2019

安装环境

系统版本 macOS 10.14.3 MySQL版本 8.0.15-x86_64

文件下载

MySQL server MySQL connector client

从安装文档得知 MySQL connector installation document 需要预先安装 iODBC

iobc 直接一键安装,下一步就好;server安装的时候需要注意你填写的 Admin 密码,以后会使用到

MySQL 环境变量

export MySQL=/usr/local/mysql/
export PATH=$PATH:$MySQL/bin
// source ~/.bash_profile
source ~/.zshrc

测试安装

$ mysql --version
mysql Ver 8.0.15 for macos10.14 on x86_64 (MySQL Community Server - GPL)

连接数据库

Mac -> 系统设置 -> MySQL 检查是否启动,没有启动先点击 Start MySQL Server 启动,输入系统管理员密码

$ mysql
$ mysql -u root -p -P 3306

可能遇到的错误

ERROR 1045 (28000): Access denied for user 'tanlin'@'localhost' (using password: NO)

需要使用密码连接,MySQL不识别当前登录的用户 tanlin 请使用指定用户名和密码 mysql -u root -p -P 3306 登录到server
小写的p是指密码 password,大写的P是指端口 Port,u 是以什么身份登录 user

$ mysql -u root -p -P 3306
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.15 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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 server 了
mysql>

退出MySQL

mysql> quit
Bye