配置yum源
- 此处主要是为了安装其他软件方便,mysql有自己的noarch。
安装base repo源
cd /etc/yum.repos.d mv CentOS-Base.repo CentOS-Base.repo.bak

wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

安装epel repo源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

清理缓存
yum clean all
重新生成缓存
yum makecache

测试安装wget
yum search wget yum remove wget

yum -y install wget

安装mysql源
安装noarch
- 打开网址 http://repo.mysql.com/ 查找最近时间的mysql57的源地址
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm #注意查找mysql57*-el7-noarch.rpm的文件 yum install mysql57-*.rpm

安装mysql
·
yum install mysql-server
·

- 注意,如果上面的命令不能安装mysql,那么需要删除上述noarch包,rpm -qa | grep mysql 查找mysql57.noarch包名,或者直接运行命令yum remove mysql57.noarch删除。
启动服务
systemctl start mysqld.service
查看mysql服务状态
systemctl is-active mysqld.service \# systemctl status mysqld.service 也可以

查看是否开机启动
systemctl is-enabled mysqld.service

设置密码
修改配置文件,设置跳过登录密码选项
vi /etc/my.cnf
- 加入 skip-grant-tables ,wq 保存。

重启服务
systemctl restart mysqld.service
登录修改密码 `
mysql -uroot
Mysql>use mysql; Mysql>update user set authentication_string=password(‘123456’) where user=’root’; \#各个版本中保存密码的字段不同,可以用desc user;命令查看user表定义,有的版本是password字段。 Mysql>flush privileges; Mysql>exit;

重启服务生效
systemctl restart mysqld.service
数据库运维安装部分完毕,谢谢您。
网友评论