1 下载 MySQL
下载 mysql-8.0.13-macos10.14-x86_64.dmg
下载即可或者官网,选择下载平台。
2 安装 MySQL
打开安装包,按照提示安装即可,最关键的一步,就是设置root密码
建立 数据库连接 的时候要用。
3 使用 MySQL
3.1 启动 / 停止 / 重启 MySQL 服务
命令
# 启动 MySQL 服务
sudo /usr/local/MySQL/support-files/mysql.server start
# 停止 MySQL 服务
sudo /usr/local/mysql/support-files/mysql.server stop
# 重启 MySQL 服务
sudo /usr/local/mysql/support-files/mysql.server restart
MySQL配置界面
MySQL配置界面
也可以手动 启动 / 停止 MySQL服务
启动 / 停止 MySQL服务启动 MySQL,报错
jake@Jake:~/Documents/demo$ sudo /usr/local/MySQL/support-files/mysql.server start
Password:
Starting MySQL
.Logging to '/usr/local/mysql/data/Jake.local.err'.
.................................................................................................... ERROR! The server quit without updating PID file (/usr/local/mysql/data/Jake.local.pid).
解决
那是因为 MySQL 已经启动,停止MySQL服务,再次使用启动命令
或者直接使用即可
jake@Jake:/usr/local/mysql/bin$ sudo /usr/local/MySQL/support-files/mysql.server start
Password:
Starting MySQL
. SUCCESS!
使用 MySQL
切换目录到 /usr/local/mysql/bin ,输入下面命令
# 和 127.0.0.1 发生关系
jake@Jake:/usr/local/mysql/bin$ mysql -uroot -h 127.0.0.1 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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>
mysql 命令
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
验证安装成功
jake@Jake:/usr/local/mysql/bin$ mysqladmin --version
mysqladmin Ver 8.0.13 for macos10.14 on x86_64 (MySQL Community Server - GPL)
网友评论