当前位置:   article > 正文

Mac安装mysql及设置_mac brew安装mysql

mac brew安装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;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/654352
推荐阅读
相关标签
  

闽ICP备14008679号