由于centos7内置了mariadb,故安装mysql有点麻烦。下面列出安装步骤。
首先,需要卸载mariadb:
1.#列出所有被安装的rpm package: rpm -qa | grep mariadb, 得到:
mariadb-5.5.41-2.el7_0.x86_64
mariadb-libs-5.5.41-2.el7_0.x86_64
mariadb-server-5.5.41-2.el7_0.x86_64
2.强制卸载以上安装包:
rpm -e --nodepsmariadb-5.5.41-2.el7_0.x86_64
rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64
rpm -e --nodeps mariadb-server-5.5.41-2.el7_0.x86_64
然后,才可以安装mysql:
1.首先安装带有当前可用的mysql5系列社区版资源的rpm包
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
2.然后安装mysql
yum install mysql-community-server
接下来,开启mysql的远程访问:
首先,关闭防火墙:
systemctl stop firewalld.service #停止
systemctl disable firewalld.service #禁用
然后,登录mysql并开启远程访问:
service mysqld start
mysql -uroot
set password for 'root'@'localhost' = password('123456');
grant all PRIVILEGES on *.* to root@'%' identified by '123456';