环境:CentOS-7.0-1406-x86_64-DVD.iso 一、yum源安装
要在线安装发现yum源没有mysql安装包,更换几次yum源,发现行不通 2)需要到mysql的官网下载yum repo配置文件。 下载命令: wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm3)然后进行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-server3)启动mysql: 这里我运行时报错了,做了两次修改①②
systemctl start mysqld4)获取临时密码:
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] Abortingmysql中的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.