Mac M1开发环境的安装与配置(mysql)


前言

第一次使用mac ,也是第一次使用M1 pro 芯片。希望能为和我一样刚接触mac的小白,避坑。由于我们是对mac完全不了解的,此文章大多数采用能简单安装就简单安装的理论为大家铺路了。
首先介绍下我的电脑配置:14寸 M1 pro 10核 32G内存1T固态


mysql的安装

1.前提

因为我们之前已经安装过了homebrew,所以这边我们选择用homebrew来安装mysql

上一篇文章:Mac M1开发环境的安装与配置(Homebrew)

2.安装mysql

打开终端 输入命令 : brew install mysql
在这里插入图片描述

3.启动服务

打开终端 输入命令 : brew services start mysql
该命令同时会在~/Library/LaunchAgents添加 homebrew.mxcl.mysql.plist(从mysql文件夹中复制过来),设置mysql的开机启动
在这里插入图片描述

4.安全启动向导设置密码

mysql_secure_installation

shenlingchao@shenlingchaodebijibendiannao ~ % mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT 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 component?

Press y|Y for Yes, any other key for No: y # y表示密码长度必须要设置为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

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 # 设置密码强度
Please set the password for root here.

New password: # 设置新密码

Re-enter new password: 
Sorry, passwords do not match. # 这边是我输入错误了。。

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
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 # n表示允许root远程登录

 ... 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.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y # 删除test库以及对test库的访问权限。
 - 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! 
shenlingchao@shenlingchaodebijibendiannao ~ % 

5.使用默认免密登陆设置密码

mysql -u root
alter user 'root'@'localhost' identified with 你的密码 by 'root';

6.查看.my.cnf配置文件

mysqld --help --verbose | less

7.常用命令

brew安装的mysql必须使用brew命令,mysql.server stop不起作用

# 启动 mysql, 并设置为开机启动
brew services start mysql

# 关闭 mysql
brew services stop mysql

# 重启 mysql
brew services restart mysql

猜你喜欢

转载自blog.csdn.net/weixin_41317840/article/details/128755984