Mysql系列——数据库运维(1)——数据库版本介绍及安装-yum

来源:互联网 发布:淘宝网无法正常显示 编辑:程序博客网 时间:2024/06/05 20:54

配置yum源

  • 此处主要是为了安装其他软件方便,mysql有自己的noarch。

安装base repo源

`
cd /etc/yum.repos.d

mv CentOS-Base.repo CentOS-Base.repo.bak
`

mv.png


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

base-repo.png

安装epel repo源


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

epel-repo.png

清理缓存


yum clean all

重新生成缓存


yum makecache

makecache.png

测试安装wget


yum search wget
yum remove wget

removewget.png


yum -y install wget

installwget.png

安装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

mysqlnoarch.png

安装mysql

·
yum install mysql-server
·

yummysql-server.png

  • 注意,如果上面的命令不能安装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-start.png

查看是否开机启动


systemctl is-enabled mysqld.service

systemctl-enabled.png

设置密码

修改配置文件,设置跳过登录密码选项


vi /etc/my.cnf

  • 加入 skip-grant-tables ,wq 保存。

grantcnf.png

重启服务


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;

changepass.png

重启服务生效


systemctl restart mysqld.service

数据库运维安装部分完毕,谢谢您。

阅读全文
1 0
原创粉丝点击