Mac 下安装 MySQL 经历

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 1.使用 homebrew 安装:brew install mysql结果报错:$ brew install mysql==> Downloading http://dev.mysql.com/get/Downloads/MySQL-5.

1.使用 homebrew 安装:

brew install mysql

结果报错:

$ brew install mysql
==> Downloading http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19.tar.gz/from/http://cdn.mysql.com/

curl: (22) The requested URL returned error: 404 Not Found
Error: Download failed: http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19.tar.gz/from/http://cdn.mysql.com/

这时升级一下你的 homebrew:

brew update

安装完成后,然后又报错:

Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/man/man8/mysqld.8
/usr/local/share/man/man8 is not writable.

真是坎坷。。。

解决方法:

#开启权限 
$ sudo chown -R $(whoami) /usr/local/ 
#重新link一次 
$ brew link mysql

这下总算安装完成了。

 

2.配置 mysql :

进入 sql 指令模式:

mysql -uroot -p

然后报错:

Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

表明我们没有启动 mysql 服务。

所以启动服务:

mysql.server start

 

3.设置 root 账户密码:

mysql_secure_installation

 

然后出现下列配置选项:

(1)

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:
Please set the password for root here.
New password:
Re-enter new password:

询问你是否安装 VALLDATE PASSWORD 这个套件(可以帮助你验证密码的复杂度,设置的太简单会提醒你),我并没有安装这个套件,直接 enter 后输入两次密码结束。

(2)

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 。

(3)

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) :

是否关闭 root 远端登入?选 y 。

(4)

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 。

(5)

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 。

 

4.再次尝试进入 sql 指令模式:

mysql -uroot -p

成功!

 

到这步我们便完成了 MySQL 的安装。

 

******

 

以Service方式启动/停止/重启MySQL命令:

service mysqld start

service mysqld stop

service mysqld restart

 

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
10天前
|
关系型数据库 MySQL 数据库
mysql卸载、下载、安装(window版本)
mysql卸载、下载、安装(window版本)
|
2天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
10 0
|
2天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
29 2
|
6天前
|
Java Android开发 芯片
Mac M芯片安装DBeaver Ultimate
Mac M芯片安装DBeaver Ultimate
10 0
Mac M芯片安装DBeaver Ultimate
|
6天前
|
关系型数据库 MySQL 数据安全/隐私保护
MySQL 安装及连接
MySQL 安装及连接
23 0
|
9天前
|
关系型数据库 MySQL 数据库
docker自定义安装mysql 5.7
docker自定义安装mysql 5.7
19 0
|
9天前
|
关系型数据库 MySQL Linux
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
44 0
|
9天前
|
关系型数据库 MySQL Linux
win安装mysql5.7 和安装出现的问题
win安装mysql5.7 和安装出现的问题
11 0
|
关系型数据库 MySQL 数据库
MySQL 在 Mac 下的安装|学习笔记
快速学习MySQL 在 Mac 下的安装
273 0
MySQL 在 Mac 下的安装|学习笔记
|
1月前
|
开发工具 git iOS开发
Mac 安装软件包管理工具Homebrew
Mac 安装软件包管理工具Homebrew