欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

centos6.5中rpm包安装mysql5.7初始化出错的解决方法

程序员文章站 2023-10-30 20:09:46
1、rz上传到服务器,解压缩 rz [root@mini2 upload]# tar -xvf mysql-5.7.19-1.el6.i686.rpm-bund...

1、rz上传到服务器,解压缩

rz
[root@mini2 upload]# tar -xvf mysql-5.7.19-1.el6.i686.rpm-bundle.tar   

2、安装rpm包

rpm -ivh mysql-community-common-5.7.19-1.el6.i686.rpm
rpm -ivh mysql-community-libs-5.7.19-1.el6.i686.rpm 
rpm -ivh mysql-community-libs-compat-5.7.19-1.el6.i686.rpm
rpm -ivh mysql-community-client-5.7.19-1.el6.i686.rpm
rpm -ivh mysql-community-server-5.7.19-1.el6.i686.rpm

注意:如果不是全新安装,而是之前用rpm装过,没装好,又卸载的情况下安装,可能会出现如下情况:

在执行rpm -ivh mysql-community-server-5.7.19-1.el6.i686.rpm时,如果出现如下输出:

有比较大的可能是因为数据目录没有清空,我们再往下手动初始化看看,执行以下命令:

[root@mini2 upload]# mysqld --initialize --user=mysql  
2017-08-29t05:22:18.750237z 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-29t05:22:18.754943z 0 [error] --initialize specified but the data directory has files in it. aborting.
2017-08-29t05:22:18.755064z 0 [error] aborting

发现报错了,拿错误信息在百度上找了瞎,发现需要清空数据目录:

从官方的文档看到,数据目录位置:

那就清空了再试试吧。

[root@mini2 upload]# rm -rf /var/lib/mysql/*

接下来初始化:

mysqld --initialize --user=mysql

接下来启动mysql:

[root@mini2 upload]# service mysqld start 

正在启动 mysqld:                                          [确定]
 

3、查找初始密码(我这边之所以有两个密码,应该就是之前没卸载干净,直觉应该用后边的新密码登录)

[root@mini2 upload]# grep 'temporary password' /var/log/mysqld.log
2017-08-29t05:00:02.613275z 1 [note] a temporary password is generated for root@localhost: tzqjmvkhh3+c
2017-08-29t05:31:51.340338z 1 [note] a temporary password is generated for root@localhost: adgwggdr%1e2

4、登录

[root@mini2 upload]# mysql -uroot -p

我这边登录是ok了,密码用的adgwggdr%1e2

5、修改密码并允许其他机器上客户端登录

alter user 'root'@'localhost' identified by '123456';
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option

总结

以上所述是小编给大家介绍的centos6.5中rpm包安装mysql5.7初始化出错的解决方法,希望对大家有所帮助