安装mysql前要先删除本机安装的mariadb
检查已经安装的mariadb列表
[root@iZ1i4qd6oynml0Z ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
然后执行删除
[root@iZ1i4qd6oynml0Z ~]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
下面开始安装mysql
更新yum源
yum update
下载mysql yum包
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装软件源
rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装mysql,后面的一直输入y就好了
yum install mysql-community-server
启动mysql
service mysqld start
查看MySQL运行状态
service mysqld status
查看mysql默认密码,最后那一串就是默认的密码
grep ‘temporary password‘ /var/log/mysqld.log
登录mysql,输入上面步骤得到的默认密码
[root@iZ1i4qd6oynml0Z ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>