1.更换yum源
1).打开http://mirrors.aliyun.com,选择centos的系统,点击帮助
2).执行命令:yum install wget -y
3).改变某些文件的名称:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
4).执行更换yum源的命令
wget -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
参考:https://blog.csdn.net/SSAA123LJIO1/article/details/106575659
5).更新本地缓存
yum clean all
yum makecache
2.查看系统中是否自带安装mysql
yum list installed | grep mysql
3.删除系统自带的mysql及其依赖(防止冲突)
yum -y remove mysql-libs.x86_64
4.安装wget命令
yum install wget -y
5.给centos添加rpm源,并且选择较新的版本
wget http://dev.mysql.com/get/mysql-community-release-e16-5.noarch.rpm
6.安装下载好的rpm文件
yum install mysql-community-release-e16-5.noarch.rpm -y
7.安装成功后,会在/etc/yum.repos.d/文件夹下增加两个文件
mysql-community.repo
mysql-community-source.repo
8.修改mysql-community.repo文件
修改要安装版本的 enable=1
9.使用yum安装mysql
yum install mysql-community-server -y
10.启动mysql服务并设置开机启动
#启动之前需要生成临时密码,需要用到证书,有可能证书过期,需要进行更新操作
yum update -y
#启动mysql服务
service mysqld start
#设置mysql开机自启
chkconfig mysqld on
11.获取mysql的临时密码
grep "password" /var/log/mysqld.log
12.使用临时密码登录
mysql -uroot -p
#输入临时密码
13.修改密码
set global validate_password_policy=0;
set global validate_password_length=1;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
14.修改远程访问权限
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
15.设置字符集为utf-8
#在[mysqld]部分添加:
character-set-server=utf8
#在文件末尾新增[client]段,并在[client]段添加:
default-character-set=utf8
参考文章:
https://www.jianshu.com/p/276d59cbc529
https://blog.csdn.net/darendu/article/details/89874564