前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Mac 下安装 MySQL 经历

Mac 下安装 MySQL 经历

作者头像
希希里之海
发布2018-05-16 15:28:37
1.8K0
发布2018-05-16 15:28:37
举报
文章被收录于专栏:weixuqin 的专栏

1.使用 homebrew 安装:

代码语言:javascript
复制
brew install mysql

结果报错:

代码语言:javascript
复制
$ 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:

代码语言:javascript
复制
brew update

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

代码语言:javascript
复制
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.

真是坎坷。。。

解决方法:

代码语言:javascript
复制
#开启权限 
$ sudo chown -R $(whoami) /usr/local/ 
#重新link一次 
$ brew link mysql

这下总算安装完成了。

2.配置 mysql :

进入 sql 指令模式:

代码语言:javascript
复制
mysql -uroot -p

然后报错:

代码语言:javascript
复制
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

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

所以启动服务:

代码语言:javascript
复制
mysql.server start

3.设置 root 账户密码:

代码语言:javascript
复制
mysql_secure_installation

然后出现下列配置选项:

(1)

代码语言:javascript
复制
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)

代码语言:javascript
复制
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)

代码语言:javascript
复制
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)

代码语言:javascript
复制
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)

代码语言:javascript
复制
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 指令模式:

代码语言:javascript
复制
mysql -uroot -p

成功!

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

******

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

service mysqld start

service mysqld stop

service mysqld restart

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017-07-30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 以Service方式启动/停止/重启MySQL命令:
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档