通用命令
[root@localhost ~]# rpm -qa | grep mysql #查看是否安装了mysql
[root@localhost ~]# rpm -qa|grep -i mariadb #查看是否安装了mariadb
[root@localhost ~]# yum -y remove maria* #删除mariadb数据库
[root@localhost ~]# mysql mysql -uroot
Mysql> set password=password('123abcd,'); #创建root密码12345qwert@!,
Mysql> grant all privileges on *.* to 'root'@'%' identified by '12345qwert@!'; 开启mysql远程
Mysql> flush privileges; #刷新mysql权限
Mysql> quit #退出Mysql
Msyql5.5安装
[root@localhost ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-server-5.5.59-1.el7.x86_64.rpm #下载mysql5.5服务端
[root@localhost ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-client-5.5.59-1.el7.x86_64.rpm #下载mysql5.5客户端
[root@localhost ~]# rpm -ivh --nodeps MySQL-server-5.5.59-1.el7.x86_64.rpm #安装服务端
[root@localhost ~]# rpm -ivh --nodeps MySQL-client-5.5.59-1.el7.x86_64.rpm #安装客户端
[root@localhost ~]# mysqlservice mysql/mysqld start
Mysql5.6安装
[root@localhost~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm #下载rpm包
[root@localhost ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm #安装rpm包
[root@localhost ~]# yum repolist all | grep mysql #看mysql安装文件
[root@localhost ~]# yum install mysql-server #下载安装mysql
[root@localhost ~]# rpm -qa | grep mysql #检查是否安装成功
[root@localhost ~]# systemctl start mysqld.service #启动mysql
[root@localhost ~]# systemctl restart mysqld.service #重启mysql
[root@localhost ~]# systemctl stop mysqld.service #停止mysql
[root@localhost ~]# systemctl enable mysqld.service #设置 mysql 开机启动
Mysql5.7安装
[root@localhost~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm #下载5.7rpm
[root@localhost~]# yum -y install mysql57-community-release-el7-10.noarch.rpm #安装yum源
[root@localhost~]# yum -y install mysql-community-server #安装mysql包
[root@localhost~]# grep "temporary password" /var/log/mysqld.log #查看随机密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码,复杂度要高';
转载请注明:IT运维空间 » Mysql » Centos7.x下安装Mysql5.5、5.6、5.7三个版本全教程