阿里云服务器删除mysql5,安装mysql8记录

先在服务器执行

[root@iz4 ~]# rpm -qa|grep -i mysql
mysql-community-client-8.0.17-1.el7.x86_64
mysql80-community-release-el7-1.noarch
mysql-community-libs-8.0.17-1.el7.x86_64
mysql-community-server-8.0.17-1.el7.x86_64
mysql-community-common-8.0.17-1.el7.x86_64
[root@iz4 ~]# rpm -e —nodeps mysql-community-client-8.0.17-1.el7.x86_64
[root@iz4 ~]# rpm -e —nodeps mysql80-community-release-el7-1.noarch
[root@iz4 ~]# rpm -e —nodeps mysql-community-libs-8.0.17-1.el7.x86_64
[root@iz4 ~]# rpm -e —nodeps mysql-community-server-8.0.17-1.el7.x86_64
[root@iz4 ~]# rpm -e —nodeps mysql-community-common-8.0.17-1.el7.x86_64

会有两个文件没删掉,用

[root@iz4 ~]# rpm -qa|grep -i mysql
root@iz4 ~]# rpm -e --nodeps mysql-community-libs-5.6.42-2.el7.x86_64
root@iz4 ~]# rpm -e --nodeps +文件名

删完之后查看应该是空的

[root@iz4 ~]# rpm -qa|grep -i mysql
[root@iz4 ~]# 

再用find查找并删除

[root@iz4 ~]# find / -name mysql
[root@iz4 ~]# rm -rf /usr/lib64/mysql
//删除所有相关路径

删完后执行命令

wget http://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum localinstall mysql80-community-release-el7-1.noarch.rpm


而后执行下面两条命令

cd /etc/yum.repos.d/
yum install mysql-community-server

安装完毕后,启动服务器,并且获得初始密码

sudo service mysqld start
grep 'A temporary password' /var/log/mysqld.log

显示:
2019-10-10T10:43:31.881434Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: plGLdU8?Fd=w//密码

mysql -u root -p进入服务器
修改密码和允许外部网络访问mysql
(mysql8.0需要密码大于8位,大小写数字特殊字符)

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'youpassword'; 
FLUSH PRIVILEGES;
update user set host='%' where user='root';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY ‘youpassword';

你可能感兴趣的:(myqsl,mysql8,阿里云,数据库)