centos7 yum安装/卸载mysql8图文教程
一:卸载安装的mysql版本
查看安装的mysql
- rpm -qa | grep -i mysql
yum移除mysql依赖(以上所有的都需要移除完)
- yum remove -y mysql-community-libs-compat-5.7.29-1.el7.x86_64
删除mysql的文件
- find / -name mysql ------------------------(查找文件的目录)
- rm -rf xxxxx ------------------------(删除mysql文件)
删除完毕即卸载完成
二:mysql8安装
- yum -y install wget----------------------------(未安装wget请先安装)
- wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
- ps:如果服务器无法与mysql建立链接请在windows浏览器中输入网址下载,通过scp上传到指定目录或ftp
- scp 文件名 user@ip:/目标路径
- scp mysql57-community-release-el7-11.noarch.rpm root@139.196.208.224:/home/mysql8
本文采取wget下载
- wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装yum源
- yum -y localinstall mysql80-community-release-el7-3.noarch.rpm
安装mysql服务
- yum -y install mysql-community-server
启动mysql服务
- systemctl start mysqld
设置开机自启
- systemctl enable mysqld---------------------(设置自启)
- systemctl daemon-reload--------------------(重启systemctl)
查看mysql的初始密码
- vim /var/log/mysqld.log
- grep "A temporary password is generated for root@localhost" /var/log/mysqld.log
通过初始密码登陆mysql
- mysql -u root -p
修改密码, 8.0后密码有要求要包含字母大小写、特殊符号、数字,上面的错误是应为新密码不符合密码规范所致
- ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mysql2019@';
设置远程登陆
方式一:
- CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Mysql2019@';
- GRANT ALL ON *.* TO 'root'@'%';
方式二:
- alter user'root'@'%' IDENTIFIED BY 'Mysql2019@'; ----------%就是设置所有IP可以访问
- flush privileges;
这时候如果你是第一次安装,没有开放防火墙端口,则通过IP是无法进行连接的,阿里云配置安全组即可!!
- firewall-cmd --permanent --add-port=3306/tcp --------------------(开放3306端口)
- firewall-cmd --reload ----------------------------------------------------- (重启防火墙)
测试连接
赞 (0)