卸载mysql8的方法: 1.查看mysql安装文件: rpm -qa |grep -i mysql 2.卸载安装文件 yum remove mysql-community-libs-8.0.21-1.el7.x86_64 yum remove mysql-community-libs-compat-8.0.21-1.el7.x86_64 yum remove mysql80-community-release-el7-3.noarch yum remove mysql-community-common-8.0.21-1.el7.x86_64 yum remove mysql-community-server-8.0.21-1.el7.x86_64 3.查看是否卸载完成: rpm -qa |grep -i mysql 4.查找mysql相关目录 find / -name mysql 5.删除相关目录 rm -rf 6.删除配置 rm -rf /etc/my.cnf 7.删除/var/log/mysqld.log rm -rf /var/log/mysqld.log 安装5.7mysql: 1.下载rpm源 rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 2.添加mysql仓库 yum repolist all | grep mysql | grep enabled 3.安装mysql yum -y install mysql-community-server 4.service mysqld start //启动 5.service mysqld status 查看启动状态 6.cat /var/log/mysqld.log | grep -i 'temporary password' 查看默认密码并打印 7.mysql -u root -p 登入 8.打开防火墙: 1).iptables -L -n 查看防火墙开发端口 2). 安装firewall插件:yum install firewalld firewalld-config 3).配置文件:/etc/firewalld/ 详细信息:开启防火墙:systemctl start firewalld 关闭防火墙:systemctl stop firewalld 设置开机启动:systemctl enable firewalld 停止并禁用开机启动:sytemctl disable firewalld 查看指定区域所有开启的端口号 firewall-cmd --zone=public --list-ports 在指定区域开启端口(如80端口号,命令方式) firewall-cmd --zone=public --add-port=80/tcp --permanent 重新启动防火墙 firewall-cmd --reload 9.SET PASSWORD = PASSWORD('123456'); 10.重新登入,use mysql 11.select host,user from user, update user set host = '%' where user = 'root';
12.flush privileges; 重新刷新权限