MySQL 安装

MySQL 安装

MacOS

  1. 下载
    download from https://dev.mysql.com/downloads/mysql/, select macOS 10.14 (x86, 64-bit), DMG Archive(.dmg file)

顺路会看到一个叫 workbench 的,可视化工具,就像看 excel 看数据库,which is recommended.

  1. 安装
    clike next all the way.

set the PATH

1
vim ~/.bash_profile
2
# 增加以下这行
3
PATH=$PATH:/usr/local/mysql/bin

Windows

同样在https://dev.mysql.com/downloads/mysql/下载,略。

Ubuntu

1
# download the configuration
2
wget https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb
3
sudo dpkg -i mysql-apt-config_0.8.14-1_all.deb
4
# default is fine, select OK and return
5
6
sudo apt update
7
sudo apt-get install mysql-server
8
# set password(spa2020)
9
# use strong password encryption
10
11
sudo mysql_secure_installation
12
# enter password
13
# n (不换root密码)
14
# Remove anonymous users? : y(删除匿名用户)
15
# Disallow root login remotely?: n(是否禁止 root 远程登录)
16
# Remove test database and access to it? : y(删除测试数据库)
17
# Reload privilege tables now? : y(立即重新加载特权表)
18
19
mysql -V # check version
20
# mysql  Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)

WSL

参见此文

macOS 和 Windows 下可以装个数据库 GUI app

  • MySQL Workbench (free & recommend)
    如同处理 excel,不用学 mysql 命令也能操作数据库啦