第一步: 下载 rpm 安装包
卸载 mariadb
# 查看 mariadb 的安装包
rpm -qa | grep mariadb
# 卸载 mariadb 的安装包
rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
# 再次查看
rpm -qa | grep mariadb
我这里使用 wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm 的方式。
当然也可以使用SFTP, 或者 直接在Linux的GUI界面的浏览器下载, 或者使用 scp 命令从 windows拷入到虚拟机。
第二步: 安装 rpm 包
sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
这里安装包的名字 根据第一步下载的文件名来,版本可能会更新。
yum install mysql-community-server
根据官方文档,以及我的测试,这一步会自动把系统安装过的mariaDB 或者别的版本的mysql卸载掉。
不需要再安装流程前,把所有类似的软件全部卸载光光,很省力。
自动就卸载了mariaDB
第三步: 打开服务
sudo systemctl start mysqld.service // 打开服务
sudo systemctl status mysqld.service // 查看状态
第四步:获取初始密码
A superuser account 'root'@'localhost
is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:
shell> sudo grep 'temporary password' /var/log/mysqld.log
Change the root password as soon as possible by logging in with the generated, temporary password and set a custom password for the superuser account:
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';