1. 发现问题

mysql启动出现报错,一直提示:

ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.pid)

详情请看启动mysql服务时一直提示ERROR The server quit without updating PID file

2. 解决问题

修改/usr/local/mysql8.0/support-files/mysql.server文件中mysqld_safe的启动选项,在第266行加上--user=root --port=3307两个选项,并使用sudo /usr/local/mysql8.0/support-files/mysql.server startsudo /usr/local/mysql8.0/support-files/mysql.server stop启动和停止服务。

$bindir/mysqld_safe --user=root --port=3307 --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args

用软链接区分不同目录。

# sudo ln -s mysql-5.7.31-macos10.14-x86_64 mysql5.7
# sudo ln -s mysql-8.0.32-macos13-arm64 mysql8.0

添加快速启动命令。

# vim ~/.bash_profile

alias mysql5.7_start="sudo /usr/local/mysql5.7/support-files/mysql.server start"
alias mysql5.7_stop="sudo /usr/local/mysql5.7/support-files/mysql.server stop"
alias mysql8.0_start="sudo /usr/local/mysql8.0/support-files/mysql.server start"
alias mysql8.0_stop="sudo /usr/local/mysql8.0/support-files/mysql.server stop"

# source ~/.bash_profile

测试链接mysql5.7和mysql8.0。

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐