Mac brew安装mysql5.7和redis3.2

1.安装mysql

brew search mysql
brew info mysql@5.7
brew install cmake openssl
brew install mysql@5.7

2.启动登陆mysql

# 设置环境变量
brew link mysql@5.7 --force
alias mysqlstart='/usr/local/Cellar/mysql@5.7/5.7.28/bin/mysql.server start'
alias mysqlstop='/usr/local/Cellar/mysql@5.7/5.7.28/bin/mysql.server stop'
alias mysqlrestart='/usr/local/Cellar/mysql@5.7/5.7.28/bin/mysql.server restart'

# 启动mysql
brew services start mysql@5.7
brew services stop mysql@5.7
brew services restart mysql@5.7
or
mysqlstart

# 初始化mysql,设置密码等
mysql_secure_installation

3.免密码输入登陆mysql

#!/usr/bin/expect

trap {
    set rows [stty rows]
    set cols [stty columns]
    stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH

spawn mysql -u root -p
expect "*password:"
# 填写设置的密码
send "******\r"
expect "*#"
interact

1.安装redis

brew search redis
brew info redis@3.2
brew install redis@3.2

2.启动redis

# 软链
brew link redis@3.2 --force

# 启动redis
brew services start redis@3.2
# 或者使用
redis-server /usr/local/etc/redis.conf

# 关闭redis服务
brew services stop redis@3.2

# 重启redis服务
brew services restart redis@3.2

# 测试redis是否启动
redis-cli ping
PONG #如果redis返回“PONG”,那么说明连接成功

3.开机启动/卸载redis

# 开机启动redis
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
 
# 停止开机启动redis
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

# 卸载redis
brew uninstall redis
rm ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

anzhihe安志合个人博客,版权所有丨 如未注明,均为原创 丨转载请注明转自:https://chegva.com/3628.html | ☆★★每天进步一点点,加油!★★☆

您可能还感兴趣的文章!

发表评论

电子邮件地址不会被公开。 必填项已用*标注