Mac 安装mysql

安装
brew install mysql

对mysql进行初始化操作
mysql_secure_installation

$ mysql_secure_installation
 
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?
 // 这个选yes的话密码长度就必须要设置为8位以上,但我只想要6位的
Press y|Y for Yes, any other key for No: N   
Please set the password for root here.
 
New password:            // 设置密码
 
Re-enter new password:     // 再一次确认密码
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    
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) : n
 
 ... skipping.
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.
 
 // 是否删除test库
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - 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.
 
All done!

登陆mysql:mysql -u root -p
启动mysql:brew services start mysql
停止mysql:brew services stop

若安装过mysql应先stop mysql


图片.png
图片.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 网上搜索了很多安装 Mac 的文章,基本上介绍安装的方法有官网下载安装包安装 和 homebrew 命令行安装,我...
    雪樰阅读 381评论 0 0
  • 先diss下自己,其实mac利用brew安装mysql还是比较简单的。但是这次安装,只要遇到问题我就网上搜,搜索结...
    涅槃Ls阅读 2,158评论 0 3
  • MacBook-Air:~ huangyong$ brew install mysql ==> CaveatsWe...
    你说你要一场阅读 299评论 0 0
  • 今年应该是最暗淡的一个春节 人生的最低谷吧 希望明年能时来运转 机会是给有准备的人的 我准备了好几年 也应该让我翻...
    艾囍阅读 181评论 0 0
  • 前天我当上我好少年了,我非常高兴。因为这是我第二次当五好少年。我第一次是扬特长好少年,这一次是会学习,而且老...
    陈政晓阅读 176评论 0 0