centos7环境yum安装mysql

6 篇文章 0 订阅
5 篇文章 0 订阅

环境:CentOS-7.0-1406-x86_64-DVD.iso
一、yum源安装

  1. 要在线安装发现yum源没有mysql安装包,更换几次yum源,发现行不通
    在这里插入图片描述
    2)需要到mysql的官网下载yum repo配置文件。
    下载命令:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

3)然后进行repo的安装:

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

执行完成后会在/etc/yum.repos.d/目录下生成两个repo文件mysql-community.repo mysql-community-source.repo
在这里插入图片描述
再次查看yum

yum repolist |grep mysql

在这里插入图片描述
接下来就可以安装了。
二、在线yum安装mysql
1)必须进入到 /etc/yum.repos.d/目录后再执行以下脚本

cd  /etc/yum.repos.d/

2)安装命令:

yum install mysql-server

3)启动mysql:
这里我运行时报错了,做了两次修改①②

systemctl start mysqld 

4)获取临时密码:

 cat  /var/log/mysqld.log |grep 'temporary password'

在这里插入图片描述
5)登录:
mysql -u root -p
[输入临时密码]
在这里插入图片描述

安装过程出的问题:
①.

Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.]

使用: journalctl -xe命令查看时:

SELinux is preventing /usr/sbin/mysqld from write access on the directory . For complete SELinux mes

解决办法:

1、/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态
SELinux status:                 enabled

2、getenforce                 ##也可以用这个命令检查

关闭SELinux:

1、临时关闭(不用重启机器):
代码如下:

setenforce 0 #设置SELinux 成为permissive模式
#setenforce 1 设置SELinux 成为enforcing模式

2、修改配置文件需要重启机器:

修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled

重启机器即可
②刚安装好的MySQL,执行service mysqld start时报错,内容如下:

2019-06-19T07:52:53.807647Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details). 
2019-06-19T07:52:53.809065Z 0 [ERROR] *–initialize specified but the data directory has files in it. Aborting.*
2019-06-19T07:52:53.809095Z 0 [ERROR] Aborting

mysql中的data目录已经有数据了,解决方案

vim /etc/my.cnf

在这里插入图片描述
可以知道data数据放在/var/lib/mysql 中
执行:

rm -rf /var/lib/mysql

重启mysql,解决。

参考文献:a.CentOS7下安装mysql5.7
b.MySQL5.7 启动报错:initialize specified but the data directory has files in it. Aborting.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值