开发者社区> 希希里之海> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

Mac 下安装 MySQL 经历

简介: 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

 

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
mac下安装mysql
mac下安装mysql 根据我的自身经验来看,windows、liunx、mac这三个平台来看,mac上安装到正常运行是最耗我时间的。因此纪录下来,下次遇到有地方可查。 1、mysql下载安装: https://dev.mysql.com/downloads/mysql/ 这里要注意的是,最好安装和你系统匹配的版本,不然后续可能会遇到一些奇怪的错误。
4269 0
Mac上安装MySQL
版权声明:欢迎转载,请注明沉默王二原创。 https://blog.csdn.net/qing_gee/article/details/73824618 本篇文章没有技术含量,重在传播。
586 0
Mac下安装MySQL
2015-07-13 15:10:32 Mac下用homebrew安装软件还是很方便的 brew install mysql 等待一会儿安装完毕后到安装目录:  /usr/local/Cellar/mysql/5.
755 0
+关注
希希里之海
在校大二学生,喜欢分享,喜欢 Python,vim 党。
55
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载