Mac安装mysql及设置


一、使用brew安装mysql

安装

终端执行brew install mysql即可安装,

启动

执行 mysql.server start启动数据库
在这里插入图片描述

查看端口和进程

使用 netstat -AaLlnW查看本机所有端口多了3306端口号
使用lsof -i :3306或者netstat -an | grep 3306查看对应端口号进程

连接数据库

使用mysql -u root可连接数据库
使用mysql -u root -p连接数据库需要输入密码(本地开发暂不使用,如按下述设置了密码需使用此命令连接数据库)
在这里插入图片描述

使用mysql数据库并修改密码

执行use mysql使用mysql数据库
在这里插入图片描述
然后执行alter USER root@localhost IDENTIFIED BY 'root123';把mysql数据库密码修改为 root123
在这里插入图片描述
执行mysql -u root -p连接数据库输入上述设置的密码,也可连接成功
在这里插入图片描述

退出数据库连接

exit;
在这里插入图片描述

关闭数据库

使用mysql.server stop关闭数据库
在这里插入图片描述

二、安装Tips记录

We’ve installed your MySQL database without a root password. To secure it run:
mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
mysql -u root

To restart mysql after an upgrade:
brew services restart mysql
Or, if you don’t want/need a background service you can just run:
/opt/homebrew/opt/mysql/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql
==> httpd
DocumentRoot is /opt/homebrew/var/www.

The default ports have been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in
/opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.

To restart httpd after an upgrade:
brew services restart httpd
Or, if you don’t want/need a background service you can just run:
/opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND
==> nginx
Docroot is: /opt/homebrew/var/www

The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To restart nginx after an upgrade:
brew services restart nginx
Or, if you don’t want/need a background service you can just run:
/opt/homebrew/opt/nginx/bin/nginx -g daemon off;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值