自学内容网 自学内容网

M4Pro安装homebrew并基于homebrew安装MySQL踩坑记录

系统偏好设置允许安装任何来源应用:sudo spctl --master-disable 

清除提示已损坏软件的安全隔离,重新安装:

xattr -cr +空格+App路径

 

安装homebrew:

/opt/homebrew/Cellar 安装包目录

/opt/homebrew/etc 默认运行目录和mysql、redis等核心配置文件目录

/opt/homebrew/var 日志等文件目录

 

JDK安装目录:/opt/homebrew/Cellar/openjdk/23.0.1

Maven安装目录:/opt/homebrew/Cellar/maven/3.9.9/libexec

 

安装git:

brew install git 

brew install git-gui

 

安装MySQL,启动端口3306:

踩坑:必须指定版本,不指定版本默认安装mysql9,不兼容mysql8

brew install mysql@8.0

MySQL安装目录:/opt/homebrew/Cellar/mysql@8.0/8.0.40_2

MySQL账户:root/Tcf@

开机自动启动:/opt/homebrew/opt/mysql@8.0/bin/mysqld_safe --datadir\=/opt/homebrew/var/mysql

brew services start mysql@8.0;

brew services stop mysql@8.0;

my.cnf配置文件目录:/opt/homebrew/etc/my.cnf

踩坑:

1 只能在安装时指定,安装后不能配置lower_case_table_names = 1,否则无法启动

2 binlog和慢查询日志文件目录需要开放权限 sudo chmod -R 777 

[mysqld]

# Only allow connections from localhost

bind-address = 0.0.0.0

mysqlx-bind-address = 0.0.0.0

# lower_case_table_names = 1

 

# 配置服务器的服务号,具备日后需要集群做准备

server-id = 1

binlog_format = ROW

 

# 开启 Binlog 并写明存放日志的位置

log_bin = /opt/homebrew/var/log/mysql/bin-log

# 指定索引文件的位置

log_bin_index = /opt/homebrew/var/log/mysql/bin-log.index

# 设置清理超过30天的日志,以免日志堆积造过多成服务器内存爆满

binlog_expire_logs_seconds = 2592000

 

# 开启慢查询

slow_query_log = 1

# 慢查询日志

slow_query_log_file = /opt/homebrew/var/log/mysql/long-query-log.log

# 慢查询时间,默认为10s

long_query_time = 10

 

# 设置东八区时区

default-time_zone = +8:00

 

# 密码策略

validate_password.length = 12

validate_password.policy = 2

validate_password.special_char_count = 2

 

 

添加环境变量:

vi .zshrc 

export PATH="/opt/homebrew/opt/mysql@8.0/bin:$PATH"

使配置生效:source .zshrc

 

清除mysql残留,扫描相关目录和文件:

brew services stop mysql;

brew services list;

brew uninstall mysql;

sudo find / -name "*mysql*" -type d 扫描目录名

sudo find / -name "*mysql*" -type f 扫描文件名

删除相关残留目录即可

brew install mysql@8.0

mysql -u root

设置密码:mysql_secure_installation

 

踩坑:

1 需要开放mysql访问端口

vim /opt/homebrew/etc/my.cnf

bind-address = 0.0.0.0

mysqlx-bind-address = 0.0.0.0

2 更改用户表访问权限

mysql -u root -p

use mysql;

Update user set host = '%' where user = 'root’ ;

Flush privilege;

3 重启mysql,使修改生效

brew services restart mysql@8.0;

 


原文地址:https://blog.csdn.net/qq_30056341/article/details/145170615

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!