Linux安装Mysql5.6

# 1.创建进入目录
mkdir -p /opt/mysql
cd /opt/mysql
# 2.卸载可能存在的mysql、mariadb
rpm -qa | grep mysql | xargs sudo rpm -e --nodeps
rpm -qa | grep mariadb | xargs sudo rpm -e --nodeps
# 3.下载客户端、服务端、历史版本兼容包
curl -O https://cdn.mysql.com/archives/mysql-5.6/MySQL-server-5.6.51-1.el7.x86_64.rpm
curl -O https://cdn.mysql.com/archives/mysql-5.6/MySQL-client-5.6.51-1.el7.x86_64.rpm
curl -O https://cdn.mysql.com/archives/mysql-5.6/MySQL-shared-compat-5.6.51-1.el7.x86_64.rpm
# 4.安装mysql
rpm -ihv MySQL-server-5.6.51-1.el7.x86_64.rpm
rpm -ihv MySQL-client-5.6.51-1.el7.x86_64.rpm
rpm -ihv MySQL-shared-compat-5.6.51-1.el7.x86_64.rpm
# 5.启动服务
service mysql start
# 6.查看原始密码
cat /root/.mysql_secret
# 6.交互式修改密码,执行后输入上一步显示的密码,然后依次输入 y 123456 123456 y n n y 
mysql_secure_installation
# 7.配置用户远程连接
mysql -uroot -p123456 -e "delete from mysql.user where host<>'localhost';"
mysql -uroot -p123456 -e "update mysql.user set host='%'where host='localhost';"
mysql -uroot -p123456 -e "flush privileges;"
# 8.退出删除目录
cd -
rm -rf /opt/mysql
posted @ 2021-07-07 15:19  java拌饭  阅读(115)  评论(0编辑  收藏  举报