一、安装mysql之前,需要先卸载centos已经有的mariadb,否则会于mysql起冲突
//查看 mariadb
rpm -qa | grep mariadb
//卸载 mariadb (不卸载相关依赖)
rpm -evh --nodeps mariadb-libs-5.5.68-1.el7.x86_64
二、安装vim
yum install -y vim
三、添加官方的yum源创建并编辑mysql-community.repo文件
vi /etc/yum.repos.d/mysql-community.repo
添加下面内容
[mysql56-community]
name=MySQL 5.6 Community Server
baseUrl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
四、安装wget
yum -y install wget
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-server
五、启动mysql
systemctl start mysqld
查看启动状态
systemctl status mysqld
六、设置root用户密码
mysqladmin -u root -p password
当显示要求输入密码时,直接摁回车,因为5.6版本安装完毕之后是没有初始密码的,接着设置密码即可
七、登录mysql
mysql -u root -p
八、开启远程链接
1)在mysql登录状态下,设置链接地址为任意地址
grant all privileges on *.* to 'root'@'%' identified by '你的密码' with grant option;
flush privileges;
2)退出mysql,开放端口
exit
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload