1.mariadb
(1)使用官方源安装 yum install mariadb-server mariadb-client -y
(2)启动并添加开机自启
systemctl start mariadb.service
systemctl enable mariadb.service
(3)安全插件初始化密码
/usr/bin/mysql_secure_installation
一般建议按以下进行配置:
Enter current password for root (enter for none): Just press the Enter button
Set root password? [Y/n]: Y
New password: your-MariaDB-root-password
Re-enter new password: your-MariaDB-root-password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: n
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
(4)卸载mariadb
mysqldump -uroot -p --database database_name >name.sql
#卸载mariadb
yum remove mariadb
#删除配置文件:
rm -f /etc/my.cnf
#删除数据目录:
rm -rf /var/lib/mysql/
2.yum安装
(1)通过官网查找需要的版本和对应的平台版本https://dev.mysql.com/downloads/repo/yum/
(2)
(3)然后在linux上输入指令
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
(4)使用以下命令安装下载的发行包:
rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
(5 )列出所有版本
yum repolist all | grep mysql
发现5.7未启用,8.0才是启用的,这里我们需要安装5.7版本的,所以把8.0的进行禁用,然后再启用5.7版本
(6)先禁用8.0版本
yum-config-manager --disable mysql80-community
运行 yum-config-manager命令提示 -bash: yum-config-manager: command not found 命令未找到,因为 yum-config-manager 在 yum-utils包里面。由于系统默