主页
文章
分类
系列
标签
Mac 安装 MySQL
发布于: 2019-1-8   更新于: 2019-1-8   收录于: 数据库 , 软件安装 , Mac
文章字数: 2124   阅读时间: 5 分钟  

Homebrew 安装 MySql

1
brew install mysql

安装过程如下

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
andyqiu@Andy-MacBook-Pro ~ % brew install mysql@8.0
==> Downloading https://formulae.brew.sh/api/formula.json
######################################################################## 100.0%
==> Fetching dependencies for mysql: icu4c, ca-certificates, openssl@1.1, libcbor, libfido2, lz4, protobuf, zlib, xz and zstd
==> Fetching icu4c
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/icu4c-72.1.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching ca-certificates
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/ca-certificates-2023-01-10.all.bottle.tar.gz
######################################################################## 100.0%
==> Fetching openssl@1.1
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/openssl%401.1-1.1.1t.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching libcbor
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/libcbor-0.10.2.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching libfido2
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/libfido2-1.12.0_1.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching lz4
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/lz4-1.9.4.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching protobuf
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/protobuf-21.12.big_sur.bottle.1.tar.gz
######################################################################## 100.0%
==> Fetching zlib
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/zlib-1.2.13.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching xz
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/xz-5.4.1.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching zstd
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/zstd-1.5.4.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching mysql
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/mysql-8.0.32.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Installing dependencies for mysql: icu4c, ca-certificates, openssl@1.1, libcbor, libfido2, lz4, protobuf, zlib, xz and zstd
==> Installing mysql dependency: icu4c
==> Pouring icu4c-72.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/icu4c/72.1: 263 files, 78MB
==> Installing mysql dependency: ca-certificates
==> Pouring ca-certificates-2023-01-10.all.bottle.tar.gz
==> Downloading https://formulae.brew.sh/api/cask.json
######################################################################## 100.0%
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /usr/local/Cellar/ca-certificates/2023-01-10: 3 files, 216.8KB
==> Installing mysql dependency: openssl@1.1
==> Pouring openssl@1.1-1.1.1t.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/openssl@1.1/1.1.1t: 8,101 files, 18.5MB
==> Installing mysql dependency: libcbor
==> Pouring libcbor-0.10.2.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libcbor/0.10.2: 31 files, 175.3KB
==> Installing mysql dependency: libfido2
==> Pouring libfido2-1.12.0_1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libfido2/1.12.0_1: 538 files, 1.2MB
==> Installing mysql dependency: lz4
==> Pouring lz4-1.9.4.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/lz4/1.9.4: 22 files, 718.6KB
==> Installing mysql dependency: protobuf
==> Pouring protobuf-21.12.big_sur.bottle.1.tar.gz
🍺  /usr/local/Cellar/protobuf/21.12: 285 files, 10.2MB
==> Installing mysql dependency: zlib
==> Pouring zlib-1.2.13.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/zlib/1.2.13: 13 files, 424.9KB
==> Installing mysql dependency: xz
==> Pouring xz-5.4.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/xz/5.4.1: 95 files, 1.6MB
==> Installing mysql dependency: zstd
==> Pouring zstd-1.5.4.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/zstd/1.5.4: 31 files, 2.5MB
==> Installing mysql
==> Pouring mysql-8.0.32.big_sur.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.32/bin/mysqld --initialize-insecure --user=andyqiu --basedir=/usr/local/Cellar/mysql/8.0.32 --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -u root

To start mysql now and restart at login:
  brew services start mysql
==> Summary
🍺  /usr/local/Cellar/mysql/8.0.32: 317 files, 298.8MB
==> Running `brew cleanup mysql`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Upgrading 1 dependent of upgraded formulae:
Disable this behaviour by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
python@3.9 3.9.5 -> 3.9.16
==> Fetching dependencies for python@3.9: gdbm, readline and sqlite
==> Fetching gdbm
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/gdbm-1.23.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching readline
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/readline-8.2.1.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching sqlite
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/sqlite-3.40.1.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching python@3.9
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/python%403.9-3.9.16.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Upgrading python@3.9
  3.9.5 -> 3.9.16 

==> Installing dependencies for python@3.9: gdbm, readline and sqlite
==> Installing python@3.9 dependency: gdbm
==> Pouring gdbm-1.23.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/gdbm/1.23: 24 files, 972.8KB
==> Installing python@3.9 dependency: readline
==> Pouring readline-8.2.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/readline/8.2.1: 50 files, 1.7MB
==> Installing python@3.9 dependency: sqlite
==> Pouring sqlite-3.40.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/sqlite/3.40.1: 11 files, 4.4MB
==> Installing python@3.9
==> Pouring python@3.9-3.9.16.big_sur.bottle.tar.gz
==> /usr/local/Cellar/python@3.9/3.9.16/bin/python3.9 -m ensurepip
==> /usr/local/Cellar/python@3.9/3.9.16/bin/python3.9 -m pip install -v --no-deps --no-index --upgrade --isolated --target=/usr/local/lib/python3.9/site-packages /usr/local/Ce
==> Caveats
Python has been installed as
  /usr/local/bin/python3.9

Unversioned and major-versioned symlinks `python`, `python3`, `python-config`, `python3-config`, `pip`, `pip3`, etc. pointing to
`python3.9`, `python3.9-config`, `pip3.9` etc., respectively, have been installed into
  /usr/local/opt/python@3.9/libexec/bin

You can install Python packages with
  pip3.9 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.9/site-packages

tkinter is no longer included with this formula, but it is available separately:
  brew install python-tk@3.9

If you do not need a specific version of Python, and always want Homebrew's `python3` in your PATH:
  brew install python3

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
🍺  /usr/local/Cellar/python@3.9/3.9.16: 3,066 files, 55.6MB
==> Running `brew cleanup python@3.9`...
Removing: /usr/local/Cellar/python@3.9/3.9.5... (3,126 files, 55.0MB)
==> Checking for dependents of upgraded formulae...
==> No broken dependents found!
==> Caveats
==> mysql
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -u root

To start mysql now and restart at login:
  brew services start mysql
==> python@3.9
Python has been installed as
  /usr/local/bin/python3.9

Unversioned and major-versioned symlinks `python`, `python3`, `python-config`, `python3-config`, `pip`, `pip3`, etc. pointing to
`python3.9`, `python3.9-config`, `pip3.9` etc., respectively, have been installed into
  /usr/local/opt/python@3.9/libexec/bin

You can install Python packages with
  pip3.9 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.9/site-packages

tkinter is no longer included with this formula, but it is available separately:
  brew install python-tk@3.9

If you do not need a specific version of Python, and always want Homebrew's `python3` in your PATH:
  brew install python3

See: https://docs.brew.sh/Homebrew-and-Python

启动 MySql

1
mysql.server start

出现以下提示,说明 mysql 服务器启动完成

1
2
Starting MySQL
. SUCCESS!

设置 MySql

在终端中执行以下命令:

1
mysql_secure_installation

出现以下提示:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.
//验证密码插件可以用来测试密码和提高安全性。它检查密码的强度,并允许用户只设置那些足够安全的密码。你愿意安装验证密码插件吗?
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No:y

// 密码验证策略有三个级别:
// 低长度 >= 8
// 中长度 >= 8,数字,混合情况,和特殊字符。
// 强长度 >= 8,数字,混合情况,特殊字符和字典文件。

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

// 0, 1, 2 分别代表 3 个不同的级别,看自己的生产环境需要的密码需求

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:0

Please set the password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :y

// 默认情况下,MySQL安装有匿名用户,
// 允许任何人在不需要的情况下登录MySQL。
// 为它们创建的用户帐户。这仅仅是为了。
// 测试,并使安装更加顺利。
// 在开始生产之前,你应该把它们去掉。
// 环境。
// 删除匿名用户?(请按y| y为Yes,任何其他关键字):

By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) :y

// 成功。
// 通常,根应该只允许连接。
// “localhost”。这确保了某人无法猜测。
// 来自网络的根密码。
// 不允许远程root登录吗?(请按y| y为Yes,任何其他关键字):
// 这里表示是否允许远程登录root用户,我这里是测试环境,选择键入Y

Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) :y

成功。

// 默认情况下,MySQL附带一个名为“test”的数据库。
// 任何人都可以访问。这也只用于测试,
// 在开始生产之前应该将其移除。
// 环境。
// 这里提示是否删除mysql的test数据库


删除测试数据库并访问它?(请按y| y为Yes,任何其他关键字):

Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) :y


// ——删除测试数据库……
// 成功。
// -删除测试数据库上的特权…
// 成功。
// 重新加载特权表将确保所有更改。
// 到目前为止,将立即生效。
// 现在重新加载权限表吗?(请按y| y为Yes,任何其他关键字):
- Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) :y


Success.
//出现此消息,说明mysql设置成功,请牢记输入的mysql密码
All done!

登录 MySql 进行测试

1
mysql -u root -p

新建用户参考 Linux 安装 MySql

Andy
Welcome to andy blog
目录
相关文章
Homebrew 安装
Homebrew 是一款免费开源的软件包管理工具,可在 macOS 和 Linux 等操作系统上安装、卸载和管理软件包。它提供了一个简单的命
2018-11-23
Linux 安装 MySQL
Linux 安装 MySql 1 2 sudo apt install mysql-server sudo systemctl status mysql #验证 MySQL 服务器正在运行 设置 root 用户密码 1 2 3 4 5 6 7 8 9 10 sudo mysql mysql > ALTER USER 'root'@'localhost' IDENTIFIED
2016-5-18
MySQL
MySql 安装 Mac Linux 基本操作 导入导出 1 2 mysqldump -h hostname -u username -p database_name -P port > file.sql # Export database mysql -u username -p database_name < file.sql # Import database 连接 1 2 3 show status where `variable_name` = 'Threads_connected';
2015-8-3
Redis
启动 Redis 1 2 3 4 redis-server /path/redis.conf # 指定配置文件启动 redis redis-cli # 开启 redis 客户端 systemctl restart redis.service # 重启 redis systemctl status redis # 检查 redis 运行状态 字符串 1 2
2019-12-24
MongoDB
基本操作 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #连接 mongodb 默认://127.0.0.1:27017 mongo
2014-7-1
Go
安装 前往 官网 下载 go1.19.4.linux-amd64.tar.gz 1 2 3 tar -C /usr/local/ -xzf go1.19.4.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin go version 看到版本号代表 go 安装成功 编译器命令 1 2 3 4 5 6 7 8 9 10 11 12
2019-12-30
C#
数据类型 类型 大小 举例 String 2 bytes/char s = “reference” bool 1 byte b = true char 2 bytes ch = ‘a’ byte 1 byte b = 0x78 short 2 bytes val = 70 int 4 bytes val = 700 long 8 bytes val
2019-7-13
Google 镜像站
通过 Nginx 反向代理搭建 Google 镜像站 Nginx 配置文件添加如下配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
2019-2-16
中华上下五千年
传说时期 前传说中的黄帝、尧、弊、禹时期 三皇五帝:“三皇”指伏羲、燧人、神农。“五帝”指黄帝、颛顼、帝
2019-1-13