- 卸载MariaDB
自CentOS7起,MariaDB替代了MySQL作为其默认支持数据库,为避免冲突,先卸载MariaDB
rpm -qa | grep mariadb
rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64
// or 强制卸载MariaDB
rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64
// 安装依赖
yum install libaio net-tools
- 安装MySQL
// 获取repo
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
// 安装repo
rpm -ivh mysql-community-release-el7-5.noarch.rpm
// 安装mysql
yum install mysql-server
// 重启服务
service mysqld restart
// 防火墙开端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
- 设置root
mysql -u root
mysql > use mysql;
mysql > update user set password=password('123456') where user='root';
mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION; //任何远程主机都可以访问数据库
mysql > exit;
网友评论