centos安装mysql5.6
1.yum下载wget
yum -y install wget
2.更换源为阿里源
2.1先备份配置文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.2下载阿里云镜像文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
新镜像文件与备份
vim查看新镜像文件,已近变更为阿里源
2.3清除缓存
yum clean all
2.4生成缓存
yum makecache
2.5更新最新源设置
yum update -y
3.下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
4.安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
5.检查是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
6.修改yum源
- 可以跳过,默认安装最新版本
- 修改版本:将对应版本的enable=0改为enable=1
enable=1指要安装的版本
vim /etc/yum.repos.d/mysql-community.repo
7.安装mysql
yum install mysql-community-server
8.启动mysql服务并设置开机启动
systemctl start mysqld
systemctl enable mysqld
systemctl daemon-reload
9.连接mysql
mysql -uroot -p
修改密码
set password for 'root'@'localhost'=password('root');
设置远程登陆