1,卸载mariadb
systemctl stop mariadb
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-5.5.52-1.el7.x86_64
rpm -e --nodeps mariadb-server-5.5.52-1.el7.x86_64
rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
2,安装mysql
yum search libaio # 检索相关信息
yum install libaio #安装依赖包
yum list installed | grep mysql #查看mysql是否安装
yum remove mysql-libs.x86_64 -y #卸载mysql
#下载mysql 安装源[MySQL Yum Repository ]
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
#添加 MySQL Yum Repository 到你的系统 repository 列表中
yum localinstall mysql-community-release-el7-5.noarch.rpm
#查看安装源是否有mysql 安装包
yum repolist enabled | grep "mysql.*-community.*"
#查看mysql版本
yum repolist all | grep mysql
#可通过修改/etc/yum.repos.d/mysql-community.repo 来启用禁用某版本
#查看当前启用的版本
yum repolist enabled | grep mysql
#安装mysql
yum install mysql-community-server
whereis mysql
systemctl start mysqld
systemctl status mysqld
systemctl stop mysqld
#配置防火墙(centos 7.x的用法),增加mysql默认端口号 3306
#如果没有防火墙也可以不用管
yum install iptables-services #安装防火墙
service iptables restart
#开放端口
firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --permanent --zone=public --add-port=3306/udp
firewall-cmd --reload
#mysql设置
mysql_secure_installation #之后按提示设置,记得设在root密码
#登陆mysql
mysql -u root -p
#grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘连接口令’
#创建wwws用户为网页用户,连接数据库
CREATE USER 'wwws'@'%' IDENTIFIED BY 'zheshimima@123456';
GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 'wwws'@'%';
#创建admins用户,允许远程连接数据库
CREATE USER 'admins'@'%' IDENTIFIED BY 'zheshimima@123456';
GRANT ALL ON *.* TO 'admins'@'%';
#使授权立刻生效
flush privileges;
#后续
参考:http://www.centoscn.com/mysql/2016/0315/6844.html